packages feed

IndentParser 0.2 → 0.2.1

raw patch · 6 files changed

+79/−31 lines, 6 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Text.ParserCombinators.Parsec.IndentParser: parse :: IndentParser tok () a -> SourceName -> [tok] -> Either ParseError a
+ Text.ParserCombinators.Parsec.IndentParser: parseFromFile :: IndentCharParser () a -> SourceName -> IO (Either ParseError a)
- Text.ParserCombinators.Parsec.IndentParser: parseTest :: (Show a) => IndentParser tok () a -> [tok] -> IO ()
+ Text.ParserCombinators.Parsec.IndentParser: parseTest :: Show a => IndentParser tok () a -> [tok] -> IO ()

Files

CHANGES view
@@ -1,15 +1,25 @@-Mon Oct 15 20:05:18 IST 2007  ppk@cse.iitk.ac.in-  * Reorganised and Nested indent Fix+Fri Oct 19 16:11:04 IST 2007  ppk@cse.iitk.ac.in+  * Version 0.2.1+    	* Added combinators parse and parseFromFile+  	* Fixed an error in the error message of lineFold.   ++Thu Oct 18 18:10:18 IST 2007  ppk@cse.iitk.ac.in+  tagged IndentParser-0.2++Wed Oct 17 19:13:46 IST 2007  ppk@cse.iitk.ac.in+  * Version 0.2+       Bugs Fix-  	* Serious trouble when indentation structures are-  	nested. Hopefully fixed.+    	* Serious trouble when indentation structures are+    	nested. Hopefully fixed.+     Reorganisation-  	* All state manipulation parsers are moved into the-  	module IndentParser.Prim which is hidden.-  	* IndentToken renamed to IndentParser.Token-  	* Redefined parser state of indent parser.-  	+    	* All state manipulation parsers are moved into the+    	module IndentParser.Prim which is hidden.+    	* IndentToken renamed to IndentParser.Token+    	* Redefined parser state of indent parser.+    Mon Oct  8 10:22:13 IST 2007  ppk@cse.iitk.ac.in   tagged IndentParser-0.1
IndentParser.cabal view
@@ -1,5 +1,5 @@ Name:	IndentParser-Version: 0.2+Version: 0.2.1 License: GPL License-File: gplv3 Maintainer:login:ppk host:cse dot iitk dot ac dot in
TODO view
@@ -4,9 +4,3 @@ * Should the interface change ? * Are there other indentation based syntactic structure   that have to be supported ?---This is the very first version. I am releasing to get important-feedback. The most important item in the todo list is obviously-testing the library. Also some research needs to be done on whether-one needs to change the interface, better names for combinators etc.
Text/ParserCombinators/Parsec/IndentParser.hs view
@@ -83,7 +83,8 @@                     -- * User state manipulation.                     getState, setState,                     -- * Running and testing.-                    runParser, parseTest+                    runParser, parse, parseFromFile,+                    parseTest,  ) where @@ -92,7 +93,9 @@                                              getState,                                              setState,                                              parseTest,-                                             runParser+                                             runParser,+                                             parse,+                                             parseFromFile                                             )  @@ -212,8 +215,8 @@    If the current block (or line fold) is empty we cannot outright   reject because the argument parser @p@ could be some parser that-  accepts an empty string.  So the stratgy we use is that in this case-  we set the indentation position to be one more than the current+  accepts an empty string.  So the strategy we use is that in this+  case we set the indentation position to be one more than the current   position. So this will gurantee that @p@, if it is a valid   indentation parser will see empty input. @@ -261,7 +264,7 @@                     else return ()     where prematureEnd = do indPos <- getIndentPos                             pos <- getPosition-                            fail ("premature block termination " +++                            fail ("premature line fold termination " ++                                      "started at " ++ show indPos ++                                      " and ended at " ++ show pos)               @@ -271,6 +274,7 @@   Having defined these parsers we can now define the parser block and   lineFold. -}+ block p = saveIndent $ do setPosBlock                           x <- p `withIndentMode` Block                           eobReached
Text/ParserCombinators/Parsec/IndentParser/Prim.hs view
@@ -22,16 +22,21 @@      -- * User state manipulation.      getState, setState,      -- * Runing and testing-     runParser, parseTest-    +     runParser, parse, parseFromFile, parseTest,+      ) where                   import  Text.ParserCombinators.Parsec hiding-    (getState, setState, parseTest, runParser)+    (        getState, setState, parseTest, runParser,+             parse, parseFromFile,+    )+ import qualified Text.ParserCombinators.Parsec.Prim as PP import Control.Monad(fmap) import Text.ParserCombinators.Parsec.Pos(initialPos) +import System.IO+ -- | The mode of the indentation parser.  data IndentMode  = NoIndent   -- ^ Ignore indentation@@ -110,8 +115,7 @@   -{- $run-+{-|     The most generic way to run an IndentParser. Use @parseTest@ for testing your parser instead.@@ -131,18 +135,52 @@                                }  +{-| +Runs the given parser on a given input stream and returns either the+result or parse error. +-}++parse :: IndentParser tok () a -- ^ The parser to run+         -> SourceName  -- ^ The name of the source (to report errors)+         -> [tok]   -- ^ The input to the parser +         -> Either ParseError a++parse p = runParser p () NoIndent +++ {-|  -This is the function analogues to parseTest of the Parsec module.-Given an indent parser @p :: IndentParser tok () a@ and a list of-tokens it runs the parser and prints the result.+Like @'parse'@ but use the contents of @SourceName@ as the input+tokens.  -} +parseFromFile :: IndentCharParser () a -- ^ The parser to run+              -> SourceName  -- ^ The file on which to run.+              -> IO (Either ParseError a)  -parseTest :: Show a => IndentParser tok () a -> [tok] -> IO ()+parseFromFile p fpath = do str <- readFile fpath+                           return $ parse p fpath str++++++{-| ++Runs the input parser on the given stream and prints the result.+Useful for testing parsers.++-}+++parseTest :: Show a => +             IndentParser tok () a -- ^ The parser to test+                 -> [tok] -- ^ The input to the parser+                 -> IO () parseTest p input = case result of                       Left err  -> do putStr "Error"; print err                       Right a   -> do print a
Text/ParserCombinators/Parsec/IndentParser/Token.hs view
@@ -129,7 +129,9 @@                                              getState,                                              setState,                                              parseTest,-                                             runParser+                                             runParser,+                                             parse,+                                             parseFromFile                                             )  import qualified Text.ParserCombinators.Parsec.Token as T