packages feed

parsec3 1.0.0.7 → 1.0.0.8

raw patch · 11 files changed

+187/−82 lines, 11 filesdep ~text

Dependency ranges changed: text

Files

Changelog view
@@ -1,3 +1,6 @@+1.0.0.8+  - adjusted to changes in parsec-1.3.6+  - really adjusted text dependency 1.0.0.7   - adjusted text dependency as is done for parsec-1.3.5   - added changelog extra source file
Text/Parsec.hs view
@@ -1,29 +1,115 @@--------------------------------------------------------------------------------- |--- Module      :  Text.Parsec--- Copyright   :  (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007--- License     :  BSD-style (see the LICENSE file)--- --- Maintainer  :  derek.a.elkins@gmail.com--- Stability   :  provisional--- Portability :  portable--- ------------------------------------------------------------------------------+{- |+Module      :  Text.Parsec+Copyright   :  (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007+License     :  BSD-style (see the LICENSE file) +Maintainer  :  aslatter@gmail.com+Stability   :  provisional+Portability :  portable++This module includes everything you need to get started writing a+parser.++By default this module is set up to parse character data. If you'd like+to parse the result of your own tokenizer you should start with the following+imports:++@+ import Text.Parsec.Prim+ import Text.Parsec.Combinator+@++Then you can implement your own version of 'satisfy' on top of the 'tokenPrim'+primitive.++-}+ module Text.Parsec-    ( module Text.Parsec.Prim+    ( -- * Parsers+      ParsecT+    , Parsec+    , token+    , tokens+    , runParserT+    , runParser+    , parse+    , parseTest+    , getPosition+    , getInput+    , getState+    , putState+    , modifyState+     -- * Combinators+    , (<|>)+    , (<?>)+    , label+    , labels+    , try+    , unexpected+    , choice+    , many+    , many1+    , skipMany+    , skipMany1+    , count+    , between+    , option+    , optionMaybe+    , optional+    , sepBy+    , sepBy1+    , endBy+    , endBy1+    , sepEndBy+    , sepEndBy1+    , chainl+    , chainl1+    , chainr+    , chainr1+    , eof+    , notFollowedBy+    , manyTill+    , lookAhead+    , anyToken+     -- * Character Parsing     , module Text.Parsec.Char-    , module Text.Parsec.Combinator-    , module Text.Parsec.String-    , module Text.Parsec.ByteString-    , module Text.Parsec.ByteString.Lazy+     -- * Error messages     , ParseError     , errorPos+     -- * Position     , SourcePos     , SourceName, Line, Column     , sourceName, sourceLine, sourceColumn     , incSourceLine, incSourceColumn     , setSourceLine, setSourceColumn, setSourceName+     -- * Low-level operations+    , manyAccum+    , tokenPrim+    , tokenPrimEx+    , runPT+    , unknownError+    , sysUnExpectError+    , mergeErrorReply+    , getParserState+    , setParserState+    , updateParserState+    , Stream+    , runParsecT+    , mkPT+    , Consumed+    , Reply+    , State+    , setPosition+    , setInput+     -- * Other stuff+    , setState+    , updateState+    , parsecMap+    , parserReturn+    , parserBind+    , parserFail+    , parserZero+    , parserPlus     ) where  import Text.Parsec.Pos@@ -31,6 +117,3 @@ import Text.Parsec.Prim import Text.Parsec.Char import Text.Parsec.Combinator-import Text.Parsec.String           hiding ( Parser, GenParser, parseFromFile )-import Text.Parsec.ByteString       hiding ( Parser, GenParser, parseFromFile )-import Text.Parsec.ByteString.Lazy  hiding ( Parser, GenParser, parseFromFile )
Text/Parsec/ByteString.hs view
@@ -8,13 +8,10 @@ -- Stability   :  provisional -- Portability :  portable -- --- Make strict ByteStrings an instance of 'Stream' with 'Char' token type.+-- Convinience definitions for working with 'C.ByteString's. -- ----------------------------------------------------------------------------- -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Text.Parsec.ByteString     ( Parser, GenParser, parseFromFile     ) where@@ -23,9 +20,6 @@ import Text.Parsec.Prim  import qualified Data.ByteString.Char8 as C--instance (Monad m) => Stream C.ByteString m Char where-    uncons = return . C.uncons  type Parser = Parsec C.ByteString () type GenParser t st = Parsec C.ByteString st
Text/Parsec/ByteString/Lazy.hs view
@@ -8,13 +8,10 @@ -- Stability   :  provisional -- Portability :  portable ----- Make lazy ByteStrings an instance of 'Stream' with 'Char' token type.+-- Convinience definitions for working with lazy 'C.ByteString's. -- ----------------------------------------------------------------------------- -{-# LANGUAGE FlexibleInstances #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Text.Parsec.ByteString.Lazy     ( Parser, GenParser, parseFromFile     ) where@@ -23,9 +20,6 @@ import Text.Parsec.Prim  import qualified Data.ByteString.Lazy.Char8 as C--instance (Monad m) => Stream C.ByteString m Char where-    uncons = return . C.uncons  type Parser = Parsec C.ByteString () type GenParser t st = Parsec C.ByteString st
Text/Parsec/Char.hs view
@@ -19,6 +19,7 @@ import Data.Char import Text.Parsec.Pos import Text.Parsec.Prim+import Control.Applicative ((*>))  -- | @oneOf cs@ succeeds if the current character is in the supplied -- list of characters @cs@. Returns the parsed character. See also@@ -52,7 +53,22 @@ -- | Parses a newline character (\'\\n\'). Returns a newline character.   newline :: (Stream s m Char) => ParsecT s u m Char-newline             = char '\n'             <?> "new-line"+newline             = char '\n'             <?> "lf new-line"++-- | Parses a carriage return character (\'\\r\') followed by a newline character (\'\\n\').+-- Returns a newline character. ++crlf :: (Stream s m Char) => ParsecT s u m Char+crlf                = char '\r' *> char '\n' <?> "crlf new-line"++-- | Parses a CRLF (see 'crlf') or LF (see 'newline') end-of-line.+-- Returns a newline character (\'\\n\').+--+-- > endOfLine = newline <|> crlf+--++endOfLine :: (Stream s m Char) => ParsecT s u m Char+endOfLine           = newline <|> crlf       <?> "new-line"  -- | Parses a tab character (\'\\t\'). Returns a tab character.  
Text/Parsec/Prim.hs view
@@ -13,7 +13,8 @@ -----------------------------------------------------------------------------     {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleContexts,-             UndecidableInstances #-}+             UndecidableInstances, ScopedTypeVariables #-}+{-# OPTIONS_HADDOCK not-home #-}  module Text.Parsec.Prim     ( unknownError@@ -67,6 +68,13 @@     , updateState     ) where ++import qualified Data.ByteString.Lazy.Char8 as CL+import qualified Data.ByteString.Char8 as C++import qualified Data.Text as Text+import qualified Data.Text.Lazy as TextL+ import qualified Control.Applicative as Applicative ( Applicative(..), Alternative(..) ) import Control.Monad() import Control.Monad.Trans@@ -299,7 +307,7 @@ infix  0 <?> infixr 1 <|> --- | The parser @p <?> msg@ behaves as parser @p@, but whenever the+-- | The parser @p \<?> msg@ behaves as parser @p@, but whenever the -- parser @p@ fails /without consuming any input/, it replaces expect -- error messages with the expect error message @msg@. --@@ -329,6 +337,7 @@ (<|>) :: (ParsecT s u m a) -> (ParsecT s u m a) -> (ParsecT s u m a) p1 <|> p2 = mplus p1 p2 +-- | A synonym for @<?>@, but as a function instead of an operator. label :: ParsecT s u m a -> String -> ParsecT s u m a label p msg   = labels p [msg]@@ -363,7 +372,29 @@ class (Monad m) => Stream s m t | s -> t where     uncons :: s -> m (Maybe (t,s)) -tokens :: (Stream s m t, Eq t)+instance (Monad m) => Stream [tok] m tok where+    uncons []     = return $ Nothing+    uncons (t:ts) = return $ Just (t,ts)+    {-# INLINE uncons #-}+++instance (Monad m) => Stream CL.ByteString m Char where+    uncons = return . CL.uncons++instance (Monad m) => Stream C.ByteString m Char where+    uncons = return . C.uncons++instance (Monad m) => Stream Text.Text m Char where+    uncons = return . Text.uncons+    {-# INLINE uncons #-}++instance (Monad m) => Stream TextL.Text m Char where+    uncons = return . TextL.uncons+    {-# INLINE uncons #-}+++tokens :: forall u s m t .+          (Stream s m t, Eq t)        => ([t] -> String)      -- Pretty print a list of tokens        -> (SourcePos -> [t] -> SourcePos)        -> [t]                  -- List of tokens to parse@@ -373,32 +404,38 @@     = ParsecT $ \s _ _ eok _ ->       eok [] s $ unknownError s tokens showTokens nextposs tts@(tok:toks)-    = ParsecT $ \(State input pos u) cok cerr eok eerr -> +    = ParsecT $ \(State input pos0 u) cok cerr eok eerr ->      let-        errEof = (setErrorMessage (Expect (showTokens tts))-                  (newErrorMessage (SysUnExpect "") pos))+        nextpos :: SourcePos -> t -> SourcePos+        nextpos pos t = nextposs pos [t] -        errExpect x = (setErrorMessage (Expect (showTokens tts))-                       (newErrorMessage (SysUnExpect (showTokens [x])) pos))+        errEof pos ts =+            (setErrorMessage (Expect (showTokens ts))+             (newErrorMessage (SysUnExpect "") pos)) -        walk []     rs = ok rs-        walk (t:ts) rs = do+        errExpect pos ts x =+            (setErrorMessage (Expect (showTokens ts))+             (newErrorMessage (SysUnExpect (showTokens [x])) pos))++        -- 'pos' is the position of the first token in the stream+        walk []     pos rs = ok pos rs+        walk allTs@(t:ts) pos rs = do           sr <- uncons rs           case sr of-            Nothing                 -> cerr $ errEof-            Just (x,xs) | t == x    -> walk ts xs-                        | otherwise -> cerr $ errExpect x+            Nothing                 -> cerr $ errEof pos allTs+            Just (x,xs) | t == x    -> walk ts (nextpos pos x) xs+                        | otherwise -> cerr $ errExpect pos allTs x -        ok rs = let pos' = nextposs pos tts-                    s' = State rs pos' u-                in cok tts s' (newErrorUnknown pos')+        ok pos rs =+            let s' = State rs pos u+            in cok tts s' (newErrorUnknown pos)     in do         sr <- uncons input         case sr of-            Nothing         -> eerr $ errEof+            Nothing         -> eerr $ errEof pos0 tts             Just (x,xs)-                | tok == x  -> walk toks xs-                | otherwise -> eerr $ errExpect x+                | tok == x  -> walk toks (nextpos pos0 x) xs+                | otherwise -> eerr $ errExpect pos0 tts x          -- | The parser @try p@ behaves like parser @p@, except that it -- pretends that it hasn't consumed any input when an error occurs.
Text/Parsec/String.hs view
@@ -12,20 +12,12 @@ -- ----------------------------------------------------------------------------- -{-# LANGUAGE FlexibleInstances #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Text.Parsec.String     ( Parser, GenParser, parseFromFile     ) where  import Text.Parsec.Error import Text.Parsec.Prim--instance (Monad m) => Stream [tok] m tok where-    uncons []     = return $ Nothing-    uncons (t:ts) = return $ Just (t,ts)-    {-# INLINE uncons #-}  type Parser = Parsec String () type GenParser tok st = Parsec [tok] st
Text/Parsec/Text.hs view
@@ -8,13 +8,10 @@ -- Stability   :  provisional -- Portability :  portable -- --- Make Text an instance of 'Stream' with 'Char' token type.+-- Convinience definitions for working with 'Text.Text'. -- ----------------------------------------------------------------------------- -{-# LANGUAGE FlexibleInstances #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Text.Parsec.Text     ( Parser, GenParser     ) where@@ -22,10 +19,6 @@ import qualified Data.Text as Text import Text.Parsec.Error import Text.Parsec.Prim--instance (Monad m) => Stream Text.Text m Char where-    uncons = return . Text.uncons-    {-# INLINE uncons #-}  type Parser = Parsec Text.Text () type GenParser st = Parsec Text.Text st
Text/Parsec/Text/Lazy.hs view
@@ -8,13 +8,10 @@ -- Stability   :  provisional -- Portability :  portable -- --- Make Text an instance of 'Stream' with 'Char' token type.+-- Convinience definitions for working with lazy 'Text.Text'. -- ----------------------------------------------------------------------------- -{-# LANGUAGE FlexibleInstances #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}- module Text.Parsec.Text.Lazy     ( Parser, GenParser     ) where@@ -22,10 +19,6 @@ import qualified Data.Text.Lazy as Text import Text.Parsec.Error import Text.Parsec.Prim--instance (Monad m) => Stream Text.Text m Char where-    uncons = return . Text.uncons-    {-# INLINE uncons #-}  type Parser = Parsec Text.Text () type GenParser st = Parsec Text.Text st
Text/Parsec/Token.hs view
@@ -38,7 +38,7 @@ type LanguageDef st = GenLanguageDef String st Identity  -- | The @GenLanguageDef@ type is a record that contains all parameterizable--- features of the 'Text.Parsec.Token' module. The module 'Text.Parsec.Language'+-- features of the "Text.Parsec.Token" module. The module "Text.Parsec.Language" -- contains some default definitions.  data GenLanguageDef s u m@@ -448,7 +448,7 @@      charControl     = do{ char '^'                         ; code <- upper-                        ; return (toEnum (fromEnum code - fromEnum 'A'))+                        ; return (toEnum (fromEnum code - fromEnum 'A' + 1))                         }      charNum         = do{ code <- decimal
parsec3.cabal view
@@ -1,5 +1,5 @@ name:           parsec3-version:        1.0.0.7+version:        1.0.0.8 cabal-version: >= 1.2.3 license:        BSD3 license-file:   LICENSE@@ -27,7 +27,7 @@         avoid module ambiguities for users just installing your package.  Your         own module ambiguities are best avoided by hiding packages.         .-        This version reflects the changes of parsec-3.1.5+        This version reflects the changes of parsec-3.1.6 extra-source-files: Changelog library     exposed-modules:@@ -46,6 +46,6 @@         Text.Parsec.Expr,         Text.Parsec.Language,         Text.Parsec.Perm-    build-depends: base >= 4 && < 5, mtl, bytestring, text >= 0.2 && < 1.1+    build-depends: base >= 4 && < 5, mtl, bytestring, text >= 0.2 && < 1.3     extensions: DeriveDataTypeable, PolymorphicComponents, FlexibleInstances,         MultiParamTypeClasses, FlexibleContexts