-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Parsing combinators
--   
--   This library provides convenient combinators for working with and
--   building parsing combinator libraries.
--   
--   Given a few simple instances, e.g. for the class
--   Text.Parser.Combinators.Parsing in
--   Text.Parser.Combinators.Parsing you get access to a large
--   number of canned definitions. Instances exist for the parsers provided
--   by parsec, attoparsec and base’s Text.Read.
@package parsers
@version 0.12.3

-- | Highlighting isn't strictly a parsing concern, but it makes more sense
--   to annotate a parser with highlighting information than to require
--   someone to completely reimplement all of the combinators to add this
--   functionality later when they need it.
module Text.Parser.Token.Highlight

-- | Tags used by the TokenParsing highlight combinator.
data Highlight
EscapeCode :: Highlight
Number :: Highlight
Comment :: Highlight
CharLiteral :: Highlight
StringLiteral :: Highlight
Constant :: Highlight
Statement :: Highlight
Special :: Highlight
Symbol :: Highlight
Identifier :: Highlight
ReservedIdentifier :: Highlight
Operator :: Highlight
ReservedOperator :: Highlight
Constructor :: Highlight
ReservedConstructor :: Highlight
ConstructorOperator :: Highlight
ReservedConstructorOperator :: Highlight
BadInput :: Highlight
Unbound :: Highlight
Layout :: Highlight
MatchedSymbols :: Highlight
LiterateComment :: Highlight
LiterateSyntax :: Highlight
instance GHC.Enum.Bounded Text.Parser.Token.Highlight.Highlight
instance GHC.Enum.Enum Text.Parser.Token.Highlight.Highlight
instance GHC.Read.Read Text.Parser.Token.Highlight.Highlight
instance GHC.Show.Show Text.Parser.Token.Highlight.Highlight
instance GHC.Classes.Ord Text.Parser.Token.Highlight.Highlight
instance GHC.Classes.Eq Text.Parser.Token.Highlight.Highlight

-- | This module implements permutation parsers. The algorithm is described
--   in:
--   
--   Parsing Permutation Phrases, by Arthur Baars, Andres Loh and
--   Doaitse Swierstra. Published as a functional pearl at the Haskell
--   Workshop 2001.
module Text.Parser.Permutation

-- | The type Permutation m a denotes a permutation parser that,
--   when converted by the permute function, parses using the base
--   parsing monad m and returns a value of type a on
--   success.
--   
--   Normally, a permutation parser is first build with special operators
--   like (<||>) and than transformed into a normal parser
--   using permute.
data Permutation m a

-- | The parser permute perm parses a permutation of parser
--   described by perm. For example, suppose we want to parse a
--   permutation of: an optional string of a's, the character
--   b and an optional c. This can be described by:
--   
--   
--   test  = permute (tuple <$?> ("",some (char 'a'))
--                          <||> char 'b'
--                          <|?> ('_',char 'c'))
--         where
--           tuple a b c  = (a,b,c)
--   
permute :: Alternative m => Permutation m a -> m a

-- | The expression perm <||> p adds parser p to
--   the permutation parser perm. The parser p is not
--   allowed to accept empty input - use the optional combinator
--   (<|?>) instead. Returns a new permutation parser that
--   includes p.
(<||>) :: Functor m => Permutation m (a -> b) -> m a -> Permutation m b

-- | The expression f <$$> p creates a fresh permutation
--   parser consisting of parser p. The final result of the
--   permutation parser is the function f applied to the return
--   value of p. The parser p is not allowed to accept
--   empty input - use the optional combinator (<$?>) instead.
--   
--   If the function f takes more than one parameter, the type
--   variable b is instantiated to a functional type which
--   combines nicely with the adds parser p to the
--   (<||>) combinator. This results in stylized code where a
--   permutation parser starts with a combining function f
--   followed by the parsers. The function f gets its parameters
--   in the order in which the parsers are specified, but actual input can
--   be in any order.
(<$$>) :: Functor m => (a -> b) -> m a -> Permutation m b

-- | The expression perm <||> (x,p) adds parser p
--   to the permutation parser perm. The parser p is
--   optional - if it can not be applied, the default value x will
--   be used instead. Returns a new permutation parser that includes the
--   optional parser p.
(<|?>) :: Functor m => Permutation m (a -> b) -> (a, m a) -> Permutation m b

-- | The expression f <$?> (x,p) creates a fresh permutation
--   parser consisting of parser p. The final result of the
--   permutation parser is the function f applied to the return
--   value of p. The parser p is optional - if it can not
--   be applied, the default value x will be used instead.
(<$?>) :: Functor m => (a -> b) -> (a, m a) -> Permutation m b
instance GHC.Base.Functor m => GHC.Base.Functor (Text.Parser.Permutation.Permutation m)
instance GHC.Base.Functor m => GHC.Base.Functor (Text.Parser.Permutation.Branch m)

-- | Alternative parser combinators
module Text.Parser.Combinators

-- | choice ps tries to apply the parsers in the list ps
--   in order, until one of them succeeds. Returns the value of the
--   succeeding parser.
choice :: Alternative m => [m a] -> m a

-- | option x p tries to apply parser p. If p
--   fails without consuming input, it returns the value x,
--   otherwise the value returned by p.
--   
--   
--   priority = option 0 (digitToInt <$> digit)
--   
option :: Alternative m => a -> m a -> m a

-- | One or none.
optional :: Alternative f => f a -> f (Maybe a)

-- | skipOptional p tries to apply parser p. It will
--   parse p or nothing. It only fails if p fails after
--   consuming input. It discards the result of p. (Plays the role
--   of parsec's optional, which conflicts with Applicative's optional)
skipOptional :: Alternative m => m a -> m ()

-- | between open close p parses open, followed by
--   p and close. Returns the value returned by
--   p.
--   
--   
--   braces  = between (symbol "{") (symbol "}")
--   
between :: Applicative m => m bra -> m ket -> m a -> m a

-- | One or more.
some :: Alternative f => forall a. f a -> f [a]

-- | Zero or more.
many :: Alternative f => forall a. f a -> f [a]

-- | sepBy p sep parses zero or more occurrences of
--   p, separated by sep. Returns a list of values
--   returned by p.
--   
--   
--   commaSep p  = p `sepBy` (symbol ",")
--   
sepBy :: Alternative m => m a -> m sep -> m [a]

-- | sepBy1 p sep parses one or more occurrences of
--   p, separated by sep. Returns a list of values
--   returned by p.
sepBy1 :: Alternative m => m a -> m sep -> m [a]

-- | sepEndBy1 p sep parses one or more occurrences of
--   p, separated and optionally ended by sep. Returns a
--   list of values returned by p.
sepEndBy1 :: Alternative m => m a -> m sep -> m [a]

-- | sepEndBy p sep parses zero or more occurrences of
--   p, separated and optionally ended by sep, ie.
--   haskell style statements. Returns a list of values returned by
--   p.
--   
--   
--   haskellStatements  = haskellStatement `sepEndBy` semi
--   
sepEndBy :: Alternative m => m a -> m sep -> m [a]

-- | endBy1 p sep parses one or more occurrences of
--   p, separated and ended by sep. Returns a list of
--   values returned by p.
endBy1 :: Alternative m => m a -> m sep -> m [a]

-- | endBy p sep parses zero or more occurrences of
--   p, separated and ended by sep. Returns a list of
--   values returned by p.
--   
--   
--   cStatements  = cStatement `endBy` semi
--   
endBy :: Alternative m => m a -> m sep -> m [a]

-- | count n p parses n occurrences of p. If
--   n is smaller or equal to zero, the parser equals to
--   return []. Returns a list of n values returned by
--   p.
count :: Applicative m => Int -> m a -> m [a]

-- | chainl p op x parser zero or more occurrences of
--   p, separated by op. Returns a value obtained by a
--   left associative application of all functions returned by
--   op to the values returned by p. If there are zero
--   occurrences of p, the value x is returned.
chainl :: Alternative m => m a -> m (a -> a -> a) -> a -> m a

-- | chainr p op x parser zero or more occurrences of
--   p, separated by op Returns a value obtained by a
--   right associative application of all functions returned by
--   op to the values returned by p. If there are no
--   occurrences of p, the value x is returned.
chainr :: Alternative m => m a -> m (a -> a -> a) -> a -> m a

-- | chainl1 p op x parser one or more occurrences of
--   p, separated by op Returns a value obtained by a
--   left associative application of all functions returned by
--   op to the values returned by p. . This parser can
--   for example be used to eliminate left recursion which typically occurs
--   in expression grammars.
--   
--   
--   expr   = term   `chainl1` addop
--   term   = factor `chainl1` mulop
--   factor = parens expr <|> integer
--   
--   mulop  = (*) <$ symbol "*"
--        <|> div <$ symbol "/"
--   
--   addop  = (+) <$ symbol "+"
--        <|> (-) <$ symbol "-"
--   
chainl1 :: Alternative m => m a -> m (a -> a -> a) -> m a

-- | chainr1 p op x parser one or more occurrences of |p|,
--   separated by op Returns a value obtained by a right
--   associative application of all functions returned by op to
--   the values returned by p.
chainr1 :: Alternative m => m a -> m (a -> a -> a) -> m a

-- | manyTill p end applies parser p zero or more
--   times until parser end succeeds. Returns the list of values
--   returned by p. This parser can be used to scan comments:
--   
--   
--   simpleComment   = do{ string "<!--"
--                       ; manyTill anyChar (try (string "-->"))
--                       }
--   
--   
--   Note the overlapping parsers anyChar and string
--   "-->", and therefore the use of the try combinator.
manyTill :: Alternative m => m a -> m end -> m [a]

-- | Additional functionality needed to describe parsers independent of
--   input type.
class Alternative m => Parsing m where skipMany p = () <$ many p skipSome p = p *> skipMany p unexpected = lift . unexpected eof = lift eof

-- | Take a parser that may consume input, and on failure, go back to where
--   we started and fail as if we didn't consume input.
try :: Parsing m => m a -> m a

-- | Give a parser a name
(<?>) :: Parsing m => m a -> String -> m a

-- | A version of many that discards its input. Specialized because it can
--   often be implemented more cheaply.
skipMany :: Parsing m => m a -> m ()

-- | skipSome p applies the parser p one or more
--   times, skipping its result. (aka skipMany1 in parsec)
skipSome :: Parsing m => m a -> m ()

-- | Used to emit an error on an unexpected token
unexpected :: Parsing m => String -> m a

-- | This parser only succeeds at the end of the input. This is not a
--   primitive parser but it is defined using notFollowedBy.
--   
--   
--   eof  = notFollowedBy anyChar <?> "end of input"
--   
eof :: Parsing m => m ()

-- | notFollowedBy p only succeeds when parser p fails.
--   This parser does not consume any input. This parser can be used to
--   implement the 'longest match' rule. For example, when recognizing
--   keywords (for example let), we want to make sure that a
--   keyword is not followed by a legal identifier character, in which case
--   the keyword is actually an identifier (for example lets). We
--   can program this behaviour as follows:
--   
--   
--   keywordLet  = try $ string "let" <* notFollowedBy alphaNum
--   
notFollowedBy :: (Parsing m, Show a) => m a -> m ()
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.State.Lazy.StateT s m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.State.Strict.StateT s m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.Reader.ReaderT e m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (Text.Parser.Combinators.Parsing m, GHC.Base.Monad m) => Text.Parser.Combinators.Parsing (Control.Monad.Trans.Identity.IdentityT m)
instance (Text.Parsec.Prim.Stream s m t, GHC.Show.Show t) => Text.Parser.Combinators.Parsing (Text.Parsec.Prim.ParsecT s u m)
instance Data.Attoparsec.Internal.Types.Chunk t => Text.Parser.Combinators.Parsing (Data.Attoparsec.Internal.Types.Parser t)
instance Text.Parser.Combinators.Parsing Text.ParserCombinators.ReadP.ReadP

-- | Parsers that can lookAhead.
module Text.Parser.LookAhead

-- | Additional functionality needed to describe parsers independent of
--   input type.
class Parsing m => LookAheadParsing m

-- | lookAhead p parses p without consuming any input.
lookAhead :: LookAheadParsing m => m a -> m a
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.State.Lazy.StateT s m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.State.Strict.StateT s m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.Reader.ReaderT e m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (Text.Parser.LookAhead.LookAheadParsing m, GHC.Base.Monad m) => Text.Parser.LookAhead.LookAheadParsing (Control.Monad.Trans.Identity.IdentityT m)
instance (Text.Parsec.Prim.Stream s m t, GHC.Show.Show t) => Text.Parser.LookAhead.LookAheadParsing (Text.Parsec.Prim.ParsecT s u m)
instance Data.Attoparsec.Internal.Types.Chunk i => Text.Parser.LookAhead.LookAheadParsing (Data.Attoparsec.Internal.Types.Parser i)
instance Text.Parser.LookAhead.LookAheadParsing Text.ParserCombinators.ReadP.ReadP

-- | A helper module to parse "expressions". Builds a parser given a table
--   of operators and associativities.
module Text.Parser.Expression

-- | This data type specifies the associativity of operators: left, right
--   or none.
data Assoc
AssocNone :: Assoc
AssocLeft :: Assoc
AssocRight :: Assoc

-- | This data type specifies operators that work on values of type
--   a. An operator is either binary infix or unary prefix or
--   postfix. A binary operator has also an associated associativity.
data Operator m a
Infix :: (m (a -> a -> a)) -> Assoc -> Operator m a
Prefix :: (m (a -> a)) -> Operator m a
Postfix :: (m (a -> a)) -> Operator m a

-- | An OperatorTable m a is a list of Operator m a
--   lists. The list is ordered in descending precedence. All operators in
--   one list have the same precedence (but may have a different
--   associativity).
type OperatorTable m a = [[Operator m a]]

-- | buildExpressionParser table term builds an expression parser
--   for terms term with operators from table, taking the
--   associativity and precedence specified in table into account.
--   Prefix and postfix operators of the same precedence can only occur
--   once (i.e. --2 is not allowed if - is prefix
--   negate). Prefix and postfix operators of the same precedence associate
--   to the left (i.e. if ++ is postfix increment, than
--   -2++ equals -1, not -3).
--   
--   The buildExpressionParser takes care of all the complexity
--   involved in building expression parser. Here is an example of an
--   expression parser that handles prefix signs, postfix increment and
--   basic arithmetic.
--   
--   
--   import Control.Applicative ((<|>))
--   import Text.Parser.Combinators ((<?>))
--   import Text.Parser.Expression
--   import Text.Parser.Token (TokenParsing, natural, parens, reserve)
--   import Text.Parser.Token.Style (emptyOps)
--   
--   expr   :: (Monad m, TokenParsing m) => m Integer
--   expr    = buildExpressionParser table term
--           <?> "expression"
--   
--   term   :: (Monad m, TokenParsing m) => m Integer
--   term    =  parens expr
--           <|> natural
--           <?> "simple expression"
--   
--   table  :: (Monad m, TokenParsing m) => [[Operator m Integer]]
--   table   = [ [prefix "-" negate, prefix "+" id ]
--             , [postfix "++" (+1)]
--             , [binary "*" (*) AssocLeft, binary "/" (div) AssocLeft ]
--             , [binary "+" (+) AssocLeft, binary "-" (-)   AssocLeft ]
--             ]
--   
--   binary  name fun assoc = Infix (fun <$ reservedOp name) assoc
--   prefix  name fun       = Prefix (fun <$ reservedOp name)
--   postfix name fun       = Postfix (fun <$ reservedOp name)
--   
--   reservedOp name = reserve emptyOps name
--   
buildExpressionParser :: (Parsing m, Applicative m) => OperatorTable m a -> m a -> m a
instance Data.Data.Data Text.Parser.Expression.Assoc
instance GHC.Enum.Bounded Text.Parser.Expression.Assoc
instance GHC.Enum.Enum Text.Parser.Expression.Assoc
instance GHC.Arr.Ix Text.Parser.Expression.Assoc
instance GHC.Read.Read Text.Parser.Expression.Assoc
instance GHC.Show.Show Text.Parser.Expression.Assoc
instance GHC.Classes.Ord Text.Parser.Expression.Assoc
instance GHC.Classes.Eq Text.Parser.Expression.Assoc

-- | Parsers for character streams
module Text.Parser.Char

-- | oneOf cs succeeds if the current character is in the supplied
--   list of characters cs. Returns the parsed character. See also
--   satisfy.
--   
--   
--   vowel  = oneOf "aeiou"
--   
oneOf :: CharParsing m => [Char] -> m Char

-- | As the dual of oneOf, noneOf cs succeeds if the
--   current character is not in the supplied list of characters
--   cs. Returns the parsed character.
--   
--   
--   consonant = noneOf "aeiou"
--   
noneOf :: CharParsing m => [Char] -> m Char

-- | oneOfSet cs succeeds if the current character is in the
--   supplied set of characters cs. Returns the parsed character.
--   See also satisfy.
--   
--   
--   vowel  = oneOf "aeiou"
--   
oneOfSet :: CharParsing m => CharSet -> m Char

-- | As the dual of oneOf, noneOf cs succeeds if the
--   current character is not in the supplied list of characters
--   cs. Returns the parsed character.
--   
--   
--   consonant = noneOf "aeiou"
--   
noneOfSet :: CharParsing m => CharSet -> m Char

-- | Skips zero or more white space characters. See also
--   skipMany.
spaces :: CharParsing m => m ()

-- | Parses a white space character (any character which satisfies
--   isSpace) Returns the parsed character.
space :: CharParsing m => m Char

-- | Parses a newline character ('\n'). Returns a newline character.
newline :: CharParsing m => m Char

-- | Parses a tab character ('\t'). Returns a tab character.
tab :: CharParsing m => m Char

-- | Parses an upper case letter. Returns the parsed character.
upper :: CharParsing m => m Char

-- | Parses a lower case character. Returns the parsed character.
lower :: CharParsing m => m Char

-- | Parses a letter or digit. Returns the parsed character.
alphaNum :: CharParsing m => m Char

-- | Parses a letter (an upper case or lower case character). Returns the
--   parsed character.
letter :: CharParsing m => m Char

-- | Parses a digit. Returns the parsed character.
digit :: CharParsing m => m Char

-- | Parses a hexadecimal digit (a digit or a letter between 'a' and 'f' or
--   'A' and 'F'). Returns the parsed character.
hexDigit :: CharParsing m => m Char

-- | Parses an octal digit (a character between '0' and '7'). Returns the
--   parsed character.
octDigit :: CharParsing m => m Char
satisfyRange :: CharParsing m => Char -> Char -> m Char

-- | Additional functionality needed to parse character streams.
class Parsing m => CharParsing m where satisfy = lift . satisfy char c = satisfy (c ==) <?> show [c] notChar c = satisfy (c /=) anyChar = satisfy (const True) string s = s <$ try (traverse_ char s) <?> show s text t = t <$ string (unpack t)

-- | Parse a single character of the input, with UTF-8 decoding
satisfy :: CharParsing m => (Char -> Bool) -> m Char

-- | char c parses a single character c. Returns the
--   parsed character (i.e. c).
--   
--   e.g.
--   
--   
--   semiColon = char ';'
--   
char :: CharParsing m => Char -> m Char

-- | notChar c parses any single character other than c.
--   Returns the parsed character.
notChar :: CharParsing m => Char -> m Char

-- | This parser succeeds for any character. Returns the parsed character.
anyChar :: CharParsing m => m Char

-- | string s parses a sequence of characters given by s.
--   Returns the parsed string (i.e. s).
--   
--   
--   divOrMod    =   string "div"
--               <|> string "mod"
--   
string :: CharParsing m => String -> m String

-- | text t parses a sequence of characters determined by the text
--   t Returns the parsed text fragment (i.e. t).
--   
--   Using OverloadedStrings:
--   
--   
--   divOrMod    =   text "div"
--               <|> text "mod"
--   
text :: CharParsing m => Text -> m Text
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m) => Text.Parser.Char.CharParsing (Control.Monad.Trans.State.Lazy.StateT s m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m) => Text.Parser.Char.CharParsing (Control.Monad.Trans.State.Strict.StateT s m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m) => Text.Parser.Char.CharParsing (Control.Monad.Trans.Reader.ReaderT e m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Char.CharParsing (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Char.CharParsing (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Char.CharParsing (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Char.CharParsing (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (Text.Parser.Char.CharParsing m, GHC.Base.MonadPlus m) => Text.Parser.Char.CharParsing (Control.Monad.Trans.Identity.IdentityT m)
instance Text.Parsec.Prim.Stream s m GHC.Types.Char => Text.Parser.Char.CharParsing (Text.Parsec.Prim.ParsecT s u m)
instance Data.Attoparsec.Internal.Types.Chunk t => Text.Parser.Char.CharParsing (Data.Attoparsec.Internal.Types.Parser t)
instance Text.Parser.Char.CharParsing Text.ParserCombinators.ReadP.ReadP

-- | Parsers that comprehend whitespace and identifier styles
--   
--   
--   idStyle    = haskellIdents { styleReserved = ... }
--   identifier = ident idStyle
--   reserved   = reserve idStyle
--   
module Text.Parser.Token

-- | Skip zero or more bytes worth of white space. More complex parsers are
--   free to consider comments as white space.
whiteSpace :: TokenParsing m => m ()

-- | This token parser parses a single literal character. Returns the
--   literal character value. This parsers deals correctly with escape
--   sequences. The literal character is parsed according to the grammar
--   rules defined in the Haskell report (which matches most programming
--   languages quite closely).
charLiteral :: TokenParsing m => m Char

-- | This token parser parses a literal string. Returns the literal string
--   value. This parsers deals correctly with escape sequences and gaps.
--   The literal string is parsed according to the grammar rules defined in
--   the Haskell report (which matches most programming languages quite
--   closely).
stringLiteral :: (TokenParsing m, IsString s) => m s

-- | This token parser behaves as stringLiteral, but for
--   single-quoted strings.
stringLiteral' :: (TokenParsing m, IsString s) => m s

-- | This token parser parses a natural number (a positive whole number).
--   Returns the value of the number. The number can be specified in
--   decimal, hexadecimal or octal. The number is
--   parsed according to the grammar rules in the Haskell report.
natural :: TokenParsing m => m Integer

-- | This token parser parses an integer (a whole number). This parser is
--   like natural except that it can be prefixed with sign (i.e. '-'
--   or '+'). Returns the value of the number. The number can be specified
--   in decimal, hexadecimal or octal. The number is
--   parsed according to the grammar rules in the Haskell report.
integer :: TokenParsing m => m Integer

-- | This token parser parses a floating point value. Returns the value of
--   the number. The number is parsed according to the grammar rules
--   defined in the Haskell report.
double :: TokenParsing m => m Double

-- | This token parser parses either natural or a float.
--   Returns the value of the number. This parsers deals with any overlap
--   in the grammar rules for naturals and floats. The number is parsed
--   according to the grammar rules defined in the Haskell report.
naturalOrDouble :: TokenParsing m => m (Either Integer Double)

-- | This token parser is like naturalOrDouble, but handles leading
--   - or +.
integerOrDouble :: TokenParsing m => m (Either Integer Double)

-- | This token parser parses a floating point value. Returns the value of
--   the number. The number is parsed according to the grammar rules
--   defined in the Haskell report.
scientific :: TokenParsing m => m Scientific

-- | This token parser parses either natural or a scientific.
--   Returns the value of the number. This parsers deals with any overlap
--   in the grammar rules for naturals and floats. The number is parsed
--   according to the grammar rules defined in the Haskell report.
naturalOrScientific :: TokenParsing m => m (Either Integer Scientific)

-- | This token parser is like naturalOrScientific, but handles
--   leading - or +.
integerOrScientific :: TokenParsing m => m (Either Integer Scientific)

-- | Token parser symbol s parses string s and
--   skips trailing white space.
symbol :: TokenParsing m => String -> m String

-- | Token parser textSymbol t parses text s and
--   skips trailing white space.
textSymbol :: TokenParsing m => Text -> m Text

-- | Token parser symbolic s parses char s and
--   skips trailing white space.
symbolic :: TokenParsing m => Char -> m Char

-- | Token parser parens p parses p enclosed in
--   parenthesis, returning the value of p.
parens :: TokenParsing m => m a -> m a

-- | Token parser braces p parses p enclosed in braces
--   ('{' and '}'), returning the value of p.
braces :: TokenParsing m => m a -> m a

-- | Token parser angles p parses p enclosed in angle
--   brackets ('<' and '>'), returning the value of p.
angles :: TokenParsing m => m a -> m a

-- | Token parser brackets p parses p enclosed in
--   brackets ('[' and ']'), returning the value of p.
brackets :: TokenParsing m => m a -> m a

-- | Token parser comma parses the character ',' and skips any
--   trailing white space. Returns the string ",".
comma :: TokenParsing m => m Char

-- | Token parser colon parses the character ':' and skips any
--   trailing white space. Returns the string ":".
colon :: TokenParsing m => m Char

-- | Token parser dot parses the character '.' and skips any
--   trailing white space. Returns the string ".".
dot :: TokenParsing m => m Char

-- | Token parser semiSep p parses zero or more occurrences
--   of p separated by semi. Returns a list of values
--   returned by p.
semiSep :: TokenParsing m => m a -> m [a]

-- | Token parser semiSep1 p parses one or more occurrences
--   of p separated by semi. Returns a list of values
--   returned by p.
semiSep1 :: TokenParsing m => m a -> m [a]

-- | Token parser commaSep p parses zero or more
--   occurrences of p separated by comma. Returns a list of
--   values returned by p.
commaSep :: TokenParsing m => m a -> m [a]

-- | Token parser commaSep1 p parses one or more
--   occurrences of p separated by comma. Returns a list of
--   values returned by p.
commaSep1 :: TokenParsing m => m a -> m [a]

-- | Additional functionality that is needed to tokenize input while
--   ignoring whitespace.
class CharParsing m => TokenParsing m where someSpace = skipSome (satisfy isSpace) nesting = id semi = token (satisfy (';' ==) <?> ";") highlight _ a = a token p = p <* (someSpace <|> pure ())

-- | Usually, someSpace consists of one or more occurrences of a
--   space. Some parsers may choose to recognize line comments or
--   block (multi line) comments as white space as well.
someSpace :: TokenParsing m => m ()

-- | Called when we enter a nested pair of symbols. Overloadable to enable
--   disabling layout
nesting :: TokenParsing m => m a -> m a

-- | The token parser |semi| parses the character ';' and skips any
--   trailing white space. Returns the character ';'. Overloadable to
--   permit automatic semicolon insertion or Haskell-style layout.
semi :: TokenParsing m => m Char

-- | Tag a region of parsed text with a bit of semantic information. Most
--   parsers won't use this, but it is indispensible for highlighters.
highlight :: TokenParsing m => Highlight -> m a -> m a

-- | token p first applies parser p and then the
--   whiteSpace parser, returning the value of p. Every
--   lexical token (token) is defined using token, this way every
--   parse starts at a point without white space. Parsers that use
--   token are called token parsers in this document.
--   
--   The only point where the whiteSpace parser should be called
--   explicitly is the start of the main parser in order to skip any
--   leading white space.
--   
--   Alternatively, one might define token as first parsing
--   whiteSpace and then parser p. By parsing whiteSpace
--   first, the parser is able to return before parsing additional
--   whiteSpace, improving laziness.
--   
--   
--   mainParser  = sum <$ whiteSpace <*> many (token digit) <* eof
--   
token :: TokenParsing m => m a -> m a

-- | This is a parser transformer you can use to disable the automatic
--   trailing space consumption of a Token parser.
newtype Unspaced m a
Unspaced :: m a -> Unspaced m a
[runUnspaced] :: Unspaced m a -> m a

-- | This is a parser transformer you can use to disable the automatic
--   trailing newline (but not whitespace-in-general) consumption of a
--   Token parser.
newtype Unlined m a
Unlined :: m a -> Unlined m a
[runUnlined] :: Unlined m a -> m a

-- | This is a parser transformer you can use to disable syntax
--   highlighting over a range of text you are parsing.
newtype Unhighlighted m a
Unhighlighted :: m a -> Unhighlighted m a
[runUnhighlighted] :: Unhighlighted m a -> m a

-- | Parses a positive whole number in the decimal system. Returns the
--   value of the number.
--   
--   This parser does NOT swallow trailing whitespace
decimal :: TokenParsing m => m Integer

-- | Parses a positive whole number in the hexadecimal system. The number
--   should be prefixed with "x" or "X". Returns the value of the number.
--   
--   This parser does NOT swallow trailing whitespace
hexadecimal :: TokenParsing m => m Integer

-- | Parses a positive whole number in the octal system. The number should
--   be prefixed with "o" or "O". Returns the value of the number.
--   
--   This parser does NOT swallow trailing whitespace
octal :: TokenParsing m => m Integer

-- | This parser parses a character literal without the surrounding
--   quotation marks.
--   
--   This parser does NOT swallow trailing whitespace
characterChar :: TokenParsing m => m Char

-- | This parser parses an integer (a whole number). This parser is like
--   natural except that it can be prefixed with sign (i.e. '-' or
--   '+'). Returns the value of the number. The number can be specified in
--   decimal, hexadecimal or octal. The number is
--   parsed according to the grammar rules in the Haskell report.
--   
--   This parser does NOT swallow trailing whitespace.
--   
--   Also, unlike the integer parser, this parser does not admit
--   spaces between the sign and the number.
integer' :: TokenParsing m => m Integer

-- | Used to describe an input style for constructors, values, operators,
--   etc.
data IdentifierStyle m
IdentifierStyle :: String -> m Char -> m Char -> HashSet String -> Highlight -> Highlight -> IdentifierStyle m
[_styleName] :: IdentifierStyle m -> String
[_styleStart] :: IdentifierStyle m -> m Char
[_styleLetter] :: IdentifierStyle m -> m Char
[_styleReserved] :: IdentifierStyle m -> HashSet String
[_styleHighlight] :: IdentifierStyle m -> Highlight
[_styleReservedHighlight] :: IdentifierStyle m -> Highlight

-- | Lift an identifier style into a monad transformer
--   
--   Using over from the lens package:
--   
--   
--   liftIdentifierStyle = over styleChars lift
--   
liftIdentifierStyle :: (MonadTrans t, Monad m) => IdentifierStyle m -> IdentifierStyle (t m)

-- | Parse a non-reserved identifier or symbol
ident :: (TokenParsing m, Monad m, IsString s) => IdentifierStyle m -> m s

-- | parse a reserved operator or identifier using a given style
reserve :: (TokenParsing m, Monad m) => IdentifierStyle m -> String -> m ()

-- | parse a reserved operator or identifier using a given style given
--   Text.
reserveText :: (TokenParsing m, Monad m) => IdentifierStyle m -> Text -> m ()

-- | This lens can be used to update the name for this style of identifier.
--   
--   
--   styleName :: Lens' (IdentifierStyle m) String
--   
styleName :: Functor f => (String -> f String) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This lens can be used to update the action used to recognize the first
--   letter in an identifier.
--   
--   
--   styleStart :: Lens' (IdentifierStyle m) (m Char)
--   
styleStart :: Functor f => (m Char -> f (m Char)) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This lens can be used to update the action used to recognize
--   subsequent letters in an identifier.
--   
--   
--   styleLetter :: Lens' (IdentifierStyle m) (m Char)
--   
styleLetter :: Functor f => (m Char -> f (m Char)) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This is a traversal of both actions in contained in an
--   IdentifierStyle.
--   
--   
--   styleChars :: Traversal (IdentifierStyle m) (IdentifierStyle n) (m Char) (n Char)
--   
styleChars :: Applicative f => (m Char -> f (n Char)) -> IdentifierStyle m -> f (IdentifierStyle n)

-- | This is a lens that can be used to modify the reserved identifier set.
--   
--   
--   styleReserved :: Lens' (IdentifierStyle m) (HashSet String)
--   
styleReserved :: Functor f => (HashSet String -> f (HashSet String)) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This is a lens that can be used to modify the highlight used for this
--   identifier set.
--   
--   
--   styleHighlight :: Lens' (IdentifierStyle m) Highlight
--   
styleHighlight :: Functor f => (Highlight -> f Highlight) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This is a lens that can be used to modify the highlight used for
--   reserved identifiers in this identifier set.
--   
--   
--   styleReservedHighlight :: Lens' (IdentifierStyle m) Highlight
--   
styleReservedHighlight :: Functor f => (Highlight -> f Highlight) -> IdentifierStyle m -> f (IdentifierStyle m)

-- | This is a traversal that can be used to modify the highlights used for
--   both non-reserved and reserved identifiers in this identifier set.
--   
--   
--   styleHighlights :: Traversal' (IdentifierStyle m) Highlight
--   
styleHighlights :: Applicative f => (Highlight -> f Highlight) -> IdentifierStyle m -> f (IdentifierStyle m)
instance Text.Parser.Char.CharParsing m => Text.Parser.Char.CharParsing (Text.Parser.Token.Unlined m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Text.Parser.Token.Unlined m)
instance GHC.Base.Monad m => GHC.Base.Monad (Text.Parser.Token.Unlined m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Text.Parser.Token.Unlined m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Text.Parser.Token.Unlined m)
instance GHC.Base.Functor m => GHC.Base.Functor (Text.Parser.Token.Unlined m)
instance Text.Parser.Char.CharParsing m => Text.Parser.Char.CharParsing (Text.Parser.Token.Unspaced m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Text.Parser.Token.Unspaced m)
instance GHC.Base.Monad m => GHC.Base.Monad (Text.Parser.Token.Unspaced m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Text.Parser.Token.Unspaced m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Text.Parser.Token.Unspaced m)
instance GHC.Base.Functor m => GHC.Base.Functor (Text.Parser.Token.Unspaced m)
instance Text.Parser.Char.CharParsing m => Text.Parser.Char.CharParsing (Text.Parser.Token.Unhighlighted m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Text.Parser.Token.Unhighlighted m)
instance GHC.Base.Monad m => GHC.Base.Monad (Text.Parser.Token.Unhighlighted m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Text.Parser.Token.Unhighlighted m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Text.Parser.Token.Unhighlighted m)
instance GHC.Base.Functor m => GHC.Base.Functor (Text.Parser.Token.Unhighlighted m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.State.Lazy.StateT s m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.State.Strict.StateT s m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.Reader.ReaderT e m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m, GHC.Base.Monoid w) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (Text.Parser.Token.TokenParsing m, GHC.Base.MonadPlus m) => Text.Parser.Token.TokenParsing (Control.Monad.Trans.Identity.IdentityT m)
instance Text.Parser.Combinators.Parsing m => Text.Parser.Combinators.Parsing (Text.Parser.Token.Unhighlighted m)
instance Control.Monad.Trans.Class.MonadTrans Text.Parser.Token.Unhighlighted
instance Text.Parser.Token.TokenParsing m => Text.Parser.Token.TokenParsing (Text.Parser.Token.Unhighlighted m)
instance Text.Parser.Combinators.Parsing m => Text.Parser.Combinators.Parsing (Text.Parser.Token.Unspaced m)
instance Control.Monad.Trans.Class.MonadTrans Text.Parser.Token.Unspaced
instance Text.Parser.Token.TokenParsing m => Text.Parser.Token.TokenParsing (Text.Parser.Token.Unspaced m)
instance Text.Parser.Combinators.Parsing m => Text.Parser.Combinators.Parsing (Text.Parser.Token.Unlined m)
instance Control.Monad.Trans.Class.MonadTrans Text.Parser.Token.Unlined
instance Text.Parser.Token.TokenParsing m => Text.Parser.Token.TokenParsing (Text.Parser.Token.Unlined m)
instance Text.Parsec.Prim.Stream s m GHC.Types.Char => Text.Parser.Token.TokenParsing (Text.Parsec.Prim.ParsecT s u m)
instance Data.Attoparsec.Internal.Types.Chunk t => Text.Parser.Token.TokenParsing (Data.Attoparsec.Internal.Types.Parser t)
instance Text.Parser.Token.TokenParsing Text.ParserCombinators.ReadP.ReadP

-- | A toolbox for specifying comment and identifier styles
--   
--   This must be imported directly as it is not re-exported elsewhere
module Text.Parser.Token.Style

-- | How to deal with comments.
data CommentStyle
CommentStyle :: String -> String -> String -> Bool -> CommentStyle

-- | String that starts a multiline comment
[_commentStart] :: CommentStyle -> String

-- | String that ends a multiline comment
[_commentEnd] :: CommentStyle -> String

-- | String that starts a single line comment
[_commentLine] :: CommentStyle -> String

-- | Can we nest multiline comments?
[_commentNesting] :: CommentStyle -> Bool

-- | This is a lens that can edit the string that starts a multiline
--   comment.
--   
--   
--   commentStart :: Lens' CommentStyle String
--   
commentStart :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle

-- | This is a lens that can edit the string that ends a multiline comment.
--   
--   
--   commentEnd :: Lens' CommentStyle String
--   
commentEnd :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle

-- | This is a lens that can edit the string that starts a single line
--   comment.
--   
--   
--   commentLine :: Lens' CommentStyle String
--   
commentLine :: Functor f => (String -> f String) -> CommentStyle -> f CommentStyle

-- | This is a lens that can edit whether we can nest multiline comments.
--   
--   
--   commentNesting :: Lens' CommentStyle Bool
--   
commentNesting :: Functor f => (Bool -> f Bool) -> CommentStyle -> f CommentStyle

-- | No comments at all
emptyCommentStyle :: CommentStyle

-- | Use java-style comments
javaCommentStyle :: CommentStyle

-- | Use scala-style comments
scalaCommentStyle :: CommentStyle

-- | Use haskell-style comments
haskellCommentStyle :: CommentStyle

-- | Use this to easily build the definition of whiteSpace for your
--   MonadParser given a comment style and an underlying someWhiteSpace
--   parser
buildSomeSpaceParser :: CharParsing m => m () -> CommentStyle -> m ()

-- | A simple identifier style based on haskell with no reserve words
emptyIdents :: TokenParsing m => IdentifierStyle m

-- | A simple identifier style based on haskell with the reserved words
--   from Haskell 98 and some common extensions.
haskellIdents :: TokenParsing m => IdentifierStyle m

-- | A simple identifier style based on haskell with only the reserved
--   words from Haskell 98.
haskell98Idents :: TokenParsing m => IdentifierStyle m

-- | A simple operator style based on haskell with no reserved operators
emptyOps :: TokenParsing m => IdentifierStyle m

-- | A simple operator style based on haskell with the operators from
--   Haskell 98.
haskellOps :: TokenParsing m => IdentifierStyle m

-- | A simple operator style based on haskell with the operators from
--   Haskell 98.
haskell98Ops :: TokenParsing m => IdentifierStyle m
instance Data.Data.Data Text.Parser.Token.Style.CommentStyle
instance GHC.Read.Read Text.Parser.Token.Style.CommentStyle
instance GHC.Show.Show Text.Parser.Token.Style.CommentStyle
instance GHC.Classes.Ord Text.Parser.Token.Style.CommentStyle
instance GHC.Classes.Eq Text.Parser.Token.Style.CommentStyle
