murder 1.1 → 1.2
raw patch · 3 files changed
+29/−24 lines, 3 filesdep ~AspectAGPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: AspectAG
API changes (from Hackage documentation)
- Language.Grammars.Murder.UUParsing: incPos :: Pos -> Pos
+ Language.Grammars.Grammar: Kw :: String -> Kw
+ Language.Grammars.Grammar: data Kw
+ Language.Grammars.Grammar: instance Idiomatic l env f g => Idiomatic l env ((Record HNil -> DTerm String) -> f) (Kw -> g)
+ Language.Grammars.Grammar: kw :: String -> Kw
+ Language.Grammars.Murder.UUParsing: expand :: Char -> Char
Files
- murder.cabal +2/−2
- src/Language/Grammars/Grammar.hs +14/−9
- src/Language/Grammars/Murder/UUParsing.hs +13/−13
murder.cabal view
@@ -1,5 +1,5 @@ name: murder -version: 1.1+version: 1.2 cabal-version: >= 1.2.3 license: LGPL license-file: COPYRIGHT@@ -13,7 +13,7 @@ copyright: Universiteit Utrecht extra-source-files: README, LICENSE-LGPL library- build-depends: base>=4 && <5, template-haskell>=2.4.0.1, TTTAS>=0.4.1, AspectAG>=0.3.4.1,+ build-depends: base>=4 && <5, template-haskell>=2.4.0.1, TTTAS>=0.4.1, AspectAG>=0.3.5, uulib>=0.9.12, uu-parsinglib >= 2.7.1, ListLike >= 3.1.0, containers>=0.3, HList>=0.2 exposed-modules: Language.Grammars.Grammar, Language.Grammars.Murder,
src/Language/Grammars/Grammar.hs view
@@ -58,9 +58,14 @@ data Pos = Pos !Line !Column | PosFile !Line !Column Filename- deriving (Show,Eq)-+ deriving (Eq) +instance Show Pos where+ show (Pos (-1) (-1)) = "Built-in"+ show (Pos l c) = "Line: " ++ show l ++ " Column: " ++ show c+ show (PosFile (-1) (-1) _) = "Built-in"+ show (PosFile l c f) = "Line: " ++ show l ++ " Column: " ++ show c ++ " File: " ++ f+ data DTerm a = DTerm {pos :: Pos, value :: a} deriving (Show, Eq) @@ -247,15 +252,15 @@ => Idiomatic l env f (String -> g) where idiomatic isf str = idiomatic (isf <* (tr str)) -{--data Pos = Pos String -pt :: String -> Pos-pt = Pos+data Kw = Kw String -instance Idiomatic l env f g => Idiomatic l env ((Record HNil -> DTerm String) -> f) (Pos -> g) where- idiomatic isf (Pos is) = idiomatic (isf <*> ((\x (Record HNil) -> x) <$> (tr is)))--}+kw :: String -> Kw+kw = Kw++instance Idiomatic l env f g => Idiomatic l env ((Record HNil -> DTerm String) -> f) (Kw -> g) where+ idiomatic isf (Kw is) = idiomatic (isf <*> ((\x (Record HNil) -> x) <$> (tr is)))+ -------------------------------------------------------------------------------
src/Language/Grammars/Murder/UUParsing.hs view
@@ -13,7 +13,7 @@ type Parser a = P (Str Char String LineCol) a pInt :: Parser Int-pInt = pInteger+pInt = pNatural -- pInteger pChr :: Parser Char pChr = pAscii @@ -35,18 +35,15 @@ spaces = pMunch (`elem` " \n") lc2Pos :: LineCol -> Pos-lc2Pos (LineCol l c) = Pos l c+lc2Pos (LineCol l c) = Pos l (c+1) -incPos :: Pos -> Pos-incPos (Pos l c ) = Pos (l+1) (c+1)-incPos (PosFile l c f) = PosFile (l+1) (c+1) f newtype Const f a s = C {unC :: f a} -- | The function 'compile' generates a parser out of a closed grammar compile :: Grammar a -> Parser a compile (Grammar (start :: Ref a env) rules) - = unC (lookupEnv start result)+ = id <$ spaces <*> (unC (lookupEnv start result)) where result = mapEnv (\ (PS ps) -> C (foldr1 (<|>) [ comp p | p <- ps]))@@ -58,14 +55,14 @@ comp (FlipStar x y) = comp x <**> comp y comp (Pure x) = pure x - comp (Sym (Term t)) = (DTerm . incPos . lc2Pos) <$> pPos <*> pTerm t+ comp (Sym (Term t)) = (DTerm . lc2Pos) <$> pPos <*> pTerm t comp (Sym (Nont n)) = unC (lookupEnv n result) - comp (Sym TermInt) = (DTerm . incPos . lc2Pos) <$> pPos <*> pInt- comp (Sym TermChar) = (DTerm . incPos . lc2Pos) <$> pPos <*> pChr- comp (Sym TermVarid) = (DTerm . incPos . lc2Pos) <$> pPos <*> pVar- comp (Sym TermConid) = (DTerm . incPos . lc2Pos) <$> pPos <*> pCon- comp (Sym TermOp) = (DTerm . incPos . lc2Pos) <$> pPos <*> pOp+ comp (Sym TermInt) = (DTerm . lc2Pos) <$> pPos <*> pInt+ comp (Sym TermChar) = (DTerm . lc2Pos) <$> pPos <*> pChr+ comp (Sym TermVarid) = (DTerm . lc2Pos) <$> pPos <*> pVar+ comp (Sym TermConid) = (DTerm . lc2Pos) <$> pPos <*> pCon+ comp (Sym TermOp) = (DTerm . lc2Pos) <$> pPos <*> pOp mapEnv :: (forall a . f a s -> g a s) @@ -79,9 +76,12 @@ | Rep a [Error LineCol] deriving Show +expand '\t' = ' '+expand c = c+ -- | The function 'parse' runs the parser for an input. parse :: Parser a -> String -> ParseResult a-parse p input = case UU.parse ( (,) <$> p <*> pEnd) (createStr (LineCol 0 0) input) of+parse p input = case UU.parse ( (,) <$> p <*> pEnd) (createStr (LineCol 1 1) (map expand input)) of (a,[] ) -> Ok a (a,msgs) -> Rep a msgs