2015-07-28 16:32:19 +03:00
|
|
|
|
-- |
|
|
|
|
|
-- Module : Text.MegaParsec
|
2015-07-30 19:20:37 +03:00
|
|
|
|
-- Copyright : © 2015 MegaParsec contributors
|
|
|
|
|
-- © 2007 Paolo Martini
|
|
|
|
|
-- © 1999–2001 Daan Leijen
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- License : BSD3
|
|
|
|
|
--
|
|
|
|
|
-- Maintainer : Mark Karpov <markkarpov@opmbx.org>
|
2015-07-29 11:38:32 +03:00
|
|
|
|
-- Stability : experimental
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- 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:
|
|
|
|
|
--
|
2015-07-29 11:38:32 +03:00
|
|
|
|
-- > import Text.MegaParsec.Prim
|
|
|
|
|
-- > import Text.MegaParsec.Combinator
|
2015-07-28 16:32:19 +03:00
|
|
|
|
--
|
|
|
|
|
-- Then you can implement your own version of 'satisfy' on top of the
|
|
|
|
|
-- 'tokenPrim' primitive.
|
2014-03-24 05:07:39 +04:00
|
|
|
|
|
2015-07-28 16:32:19 +03:00
|
|
|
|
module Text.MegaParsec
|
|
|
|
|
(
|
|
|
|
|
-- * Parsers
|
2014-03-24 05:07:39 +04:00
|
|
|
|
ParsecT
|
|
|
|
|
, Parsec
|
|
|
|
|
, token
|
|
|
|
|
, tokens
|
|
|
|
|
, runParserT
|
|
|
|
|
, runParser
|
|
|
|
|
, parse
|
2015-07-30 18:45:06 +03:00
|
|
|
|
, parseMaybe
|
2014-03-24 05:07:39 +04:00
|
|
|
|
, parseTest
|
|
|
|
|
, getPosition
|
|
|
|
|
, getInput
|
|
|
|
|
, getState
|
|
|
|
|
, putState
|
|
|
|
|
, modifyState
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- * Combinators
|
2014-03-24 05:07:39 +04:00
|
|
|
|
, (<|>)
|
|
|
|
|
, (<?>)
|
|
|
|
|
, label
|
|
|
|
|
, 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
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- * Character parsing
|
|
|
|
|
, oneOf
|
|
|
|
|
, noneOf
|
|
|
|
|
, spaces
|
|
|
|
|
, space
|
|
|
|
|
, newline
|
|
|
|
|
, crlf
|
|
|
|
|
, endOfLine
|
|
|
|
|
, tab
|
|
|
|
|
, upper
|
|
|
|
|
, lower
|
|
|
|
|
, alphaNum
|
|
|
|
|
, letter
|
|
|
|
|
, digit
|
|
|
|
|
, hexDigit
|
|
|
|
|
, octDigit
|
|
|
|
|
, char
|
|
|
|
|
, anyChar
|
|
|
|
|
, satisfy
|
|
|
|
|
, string
|
|
|
|
|
-- * Error messages
|
2008-01-13 20:53:15 +03:00
|
|
|
|
, ParseError
|
|
|
|
|
, errorPos
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- * Position
|
2008-01-13 20:53:15 +03:00
|
|
|
|
, SourcePos
|
|
|
|
|
, SourceName, Line, Column
|
|
|
|
|
, sourceName, sourceLine, sourceColumn
|
|
|
|
|
, incSourceLine, incSourceColumn
|
|
|
|
|
, setSourceLine, setSourceColumn, setSourceName
|
2015-07-28 16:32:19 +03:00
|
|
|
|
-- * Low-level operations
|
2014-03-24 05:07:39 +04:00
|
|
|
|
, tokenPrim
|
|
|
|
|
, unknownError
|
|
|
|
|
, sysUnExpectError
|
|
|
|
|
, mergeErrorReply
|
|
|
|
|
, getParserState
|
|
|
|
|
, setParserState
|
|
|
|
|
, updateParserState
|
2015-01-10 05:33:05 +03:00
|
|
|
|
, Stream (..)
|
2014-03-24 05:07:39 +04:00
|
|
|
|
, runParsecT
|
|
|
|
|
, mkPT
|
2015-01-10 05:33:05 +03:00
|
|
|
|
, Consumed (..)
|
|
|
|
|
, Reply (..)
|
|
|
|
|
, State (..)
|
2014-03-24 05:07:39 +04:00
|
|
|
|
, setPosition
|
2015-07-30 18:45:06 +03:00
|
|
|
|
, setInput )
|
2015-07-28 16:32:19 +03:00
|
|
|
|
where
|
2008-01-13 20:53:15 +03:00
|
|
|
|
|
2015-07-28 16:32:19 +03:00
|
|
|
|
import Text.MegaParsec.Char
|
|
|
|
|
import Text.MegaParsec.Combinator
|
|
|
|
|
import Text.MegaParsec.Error
|
|
|
|
|
import Text.MegaParsec.Pos
|
|
|
|
|
import Text.MegaParsec.Prim
|