peggy 0.1.2 → 0.1.3
raw patch · 2 files changed
+21/−2 lines, 2 files
Files
- Text/Peggy/Prim.hs +20/−1
- peggy.cabal +1/−1
Text/Peggy/Prim.hs view
@@ -8,9 +8,12 @@ ParseError(..), MemoTable(..), - memo, parse,+ parseString,+ parseFile, + memo,+ getPos, setPos, @@ -50,6 +53,7 @@ nullError :: ParseError nullError = ParseError (LocPos $ SrcPos "" 0 1 1) "" +errMerge :: ParseError -> ParseError -> ParseError errMerge e1@(ParseError loc1 msg1) e2@(ParseError loc2 msg2) | loc1 >= loc2 = e1 | otherwise = e2@@ -115,6 +119,21 @@ case res of Parsed _ _ ret -> return $ Right ret Failed err -> return $ Left err++parseString :: MemoTable tbl+ => (forall s . Parser tbl str s a)+ -> String+ -> str+ -> Either ParseError a+parseString p inputName str =+ parse p (SrcPos inputName 0 1 1) str++parseFile :: MemoTable tbl+ => (forall s . Parser tbl String s a)+ -> FilePath+ -> IO (Either ParseError a)+parseFile p fp =+ parse p (SrcPos fp 0 1 1) <$> readFile fp getPos :: Parser tbl str s SrcPos getPos = Parser $ \_ pos str -> return $ Parsed pos str pos
peggy.cabal view
@@ -1,5 +1,5 @@ Name: peggy-Version: 0.1.2+Version: 0.1.3 Synopsis: The Parser Generator for Haskell Description: The Parser Generator for Haskell