symantic-grammar 0.1.0.20170703 → 0.2.0.20170709
raw patch · 2 files changed
+15/−8 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Language.Symantic.Grammar.ContextFree: skipMany :: Gram_AltApp g => g a -> g ()
+ Language.Symantic.Grammar.ContextFree: manyFoldL :: Gram_AltApp g => b -> (a -> b -> b) -> g a -> g b
+ Language.Symantic.Grammar.ContextFree: manySkip :: Gram_AltApp g => g a -> g ()
+ Language.Symantic.Grammar.ContextFree: someFoldL :: Gram_AltApp g => b -> (a -> b -> b) -> g a -> g b
+ Language.Symantic.Grammar.ContextFree: someSkip :: Gram_AltApp g => g a -> g ()
- Language.Symantic.Grammar.ContextFree: class (Gram_Alt g, Gram_App g) => Gram_AltApp g where option x g = g <+> pure x optional v = Just <$> v <+> pure Nothing many a = some a <+> pure [] some a = (:) <$> a <*> many a skipMany = void . many inside f begin in_ end next = (f <$ begin <*> in_ <* end) <+> next
+ Language.Symantic.Grammar.ContextFree: class (Gram_Alt g, Gram_App g) => Gram_AltApp g where option x g = g <+> pure x optional v = Just <$> v <+> pure Nothing manyFoldL e f a = someFoldL e f a <+> pure e someFoldL e f a = f <$> a <*> manyFoldL e f a many = fmap reverse . manyFoldL [] (:) some = fmap reverse . someFoldL [] (:) manySkip = void . many someSkip = void . some inside f begin in_ end next = (f <$ begin <*> in_ <* end) <+> next
- Language.Symantic.Grammar.ContextFree: class (Gram_Terminal g, Gram_Rule g, Gram_Alt g, Gram_App g, Gram_AltApp g, Gram_CF g) => Gram_Comment g where commentable = rule3 "commentable" $ \ space line block -> skipMany $ choice [space, line, block] comment_line prefix = rule "comment_line" $ prefix *> many (any `minus` (void (char '\n') <+> eoi)) comment_block begin end = rule "comment_block" $ begin *> many (any `minus` end) <* cfOf end lexeme = rule1 "lexeme" $ \ g -> g <* commentable (void $ string " " <+> string "\n\ \ ") (void $ comment_line (string "--")) (void $ comment_block (string "{-") (string "-}")) parens = rule1 "parens" $ between (lexeme $ char '(') (lexeme $ char ')') symbol = lexeme . string
+ Language.Symantic.Grammar.ContextFree: class (Gram_Terminal g, Gram_Rule g, Gram_Alt g, Gram_App g, Gram_AltApp g, Gram_CF g) => Gram_Comment g where commentable = rule3 "commentable" $ \ space line block -> manySkip $ choice [space, line, block] comment_line prefix = rule "comment_line" $ prefix *> many (any `minus` (void (char '\n') <+> eoi)) comment_block begin end = rule "comment_block" $ begin *> many (any `minus` end) <* cfOf end lexeme = rule1 "lexeme" $ \ g -> g <* commentable (void $ string " " <+> string "\n\ \ ") (void $ comment_line (string "--")) (void $ comment_block (string "{-") (string "-}")) parens = rule1 "parens" $ between (lexeme $ char '(') (lexeme $ char ')') symbol = lexeme . string
Files
Language/Symantic/Grammar/ContextFree.hs view
@@ -6,6 +6,7 @@ import Data.Semigroup (Semigroup(..)) import Data.String (IsString(..)) import Prelude hiding (any)+import qualified Data.List as L import Language.Symantic.Grammar.Meta import Language.Symantic.Grammar.Fixity@@ -77,12 +78,18 @@ option x g = g <+> pure x optional :: g a -> g (Maybe a) optional v = Just <$> v <+> pure Nothing+ manyFoldL :: b -> (a -> b -> b) -> g a -> g b+ manyFoldL e f a = someFoldL e f a <+> pure e+ someFoldL :: b -> (a -> b -> b) -> g a -> g b+ someFoldL e f a = f <$> a <*> manyFoldL e f a many :: g a -> g [a]- many a = some a <+> pure []+ many = fmap L.reverse . manyFoldL [] (:) some :: g a -> g [a]- some a = (:) <$> a <*> many a- skipMany :: g a -> g ()- skipMany = void . many+ some = fmap L.reverse . someFoldL [] (:)+ manySkip :: g a -> g ()+ manySkip = void . many+ someSkip :: g a -> g ()+ someSkip = void . some --manyTill :: g a -> g end -> g [a] --manyTill g end = go where go = ([] <$ end) <|> ((:) <$> g <*> go) inside@@ -96,8 +103,8 @@ (f <$ begin <*> in_ <* end) <+> next deriving instance Gram_AltApp RuleEBNF instance Gram_AltApp EBNF where- many (EBNF g) = EBNF $ \rm _po -> "{" <> g rm (op, SideL) <> "}" where op = infixN0- some (EBNF g) = EBNF $ \rm _po -> "{" <> g rm (op, SideL) <> "}-" where op = infixN0+ manyFoldL _ _ (EBNF g) = EBNF $ \rm _po -> "{" <> g rm (op, SideL) <> "}" where op = infixN0+ someFoldL _ _ (EBNF g) = EBNF $ \rm _po -> "{" <> g rm (op, SideL) <> "}-" where op = infixN0 option _x (EBNF g) = EBNF $ \rm _po -> "[" <> g rm (op, SideL) <> "]" where op = infixN0 @@ -113,7 +120,7 @@ ) => Gram_Comment g where commentable :: g () -> g () -> g () -> g () commentable = rule3 "commentable" $ \space line block ->- skipMany $ choice [space, line, block]+ manySkip $ choice [space, line, block] comment_line :: CF g String -> CF g String comment_line prefix = rule "comment_line" $ prefix *> many (any `minus` (void (char '\n') <+> eoi))
symantic-grammar.cabal view
@@ -22,7 +22,7 @@ -- PVP: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.20170703+version: 0.2.0.20170709 Source-Repository head location: git://git.autogeree.net/symantic