Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hledger.Utils.Parse
Contents
Synopsis
- type SimpleStringParser a = Parsec CustomErr String a
- type SimpleTextParser = Parsec CustomErr Text
- type TextParser m a = ParsecT CustomErr Text m a
- data SourcePos = SourcePos {
- sourceName :: FilePath
- sourceLine :: !Pos
- sourceColumn :: !Pos
- mkPos :: Int -> Pos
- unPos :: Pos -> Int
- initialPos :: FilePath -> SourcePos
- showSourcePosPair :: (SourcePos, SourcePos) -> String
- showSourcePos :: SourcePos -> String
- choice' :: [TextParser m a] -> TextParser m a
- choiceInState :: [StateT s (ParsecT CustomErr Text m) a] -> StateT s (ParsecT CustomErr Text m) a
- surroundedBy :: Applicative m => m openclose -> m a -> m a
- parsewith :: Parsec e Text a -> Text -> Either (ParseErrorBundle Text e) a
- runTextParser :: TextParser Identity a -> Text -> Either (ParseErrorBundle Text CustomErr) a
- rtp :: TextParser Identity a -> Text -> Either (ParseErrorBundle Text CustomErr) a
- parsewithString :: Parsec e String a -> String -> Either (ParseErrorBundle String e) a
- parseWithState :: Monad m => st -> StateT st (ParsecT CustomErr Text m) a -> Text -> m (Either (ParseErrorBundle Text CustomErr) a)
- parseWithState' :: Stream s => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseErrorBundle s e) a
- fromparse :: (Show t, Show (Token t), Show e) => Either (ParseErrorBundle t e) a -> a
- parseerror :: (Show t, Show (Token t), Show e) => ParseErrorBundle t e -> a
- showDateParseError :: (Show t, Show (Token t), Show e) => ParseErrorBundle t e -> String
- nonspace :: TextParser m Char
- isNewline :: Char -> Bool
- isNonNewlineSpace :: Char -> Bool
- restofline :: TextParser m String
- eolof :: TextParser m ()
- spacenonewline :: (Stream s, Char ~ Token s) => ParsecT CustomErr s m Char
- skipNonNewlineSpaces :: (Stream s, Token s ~ Char) => ParsecT CustomErr s m ()
- skipNonNewlineSpaces1 :: (Stream s, Token s ~ Char) => ParsecT CustomErr s m ()
- skipNonNewlineSpaces' :: (Stream s, Token s ~ Char) => ParsecT CustomErr s m Bool
- data CustomErr
Documentation
The data type SourcePos
represents source positions. It contains the
name of the source file, a line number, and a column number. Source line
and column positions change intensively during parsing, so we need to
make them strict to avoid memory leaks.
Constructors
SourcePos | |
Fields
|
Instances
Eq SourcePos | |
Data SourcePos | |
Defined in Text.Megaparsec.Pos Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos # toConstr :: SourcePos -> Constr # dataTypeOf :: SourcePos -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) # gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # | |
Ord SourcePos | |
Read SourcePos | |
Show SourcePos | |
Generic SourcePos | |
ToJSON SourcePos Source # | |
Defined in Hledger.Data.Json | |
FromJSON SourcePos Source # | |
NFData SourcePos | |
Defined in Text.Megaparsec.Pos | |
type Rep SourcePos | |
Defined in Text.Megaparsec.Pos type Rep SourcePos = D1 ('MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-9.2.0-EAOQvYvtvOw3EHUr69Tj16" 'False) (C1 ('MetaCons "SourcePos" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "sourceLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos) :*: S1 ('MetaSel ('Just "sourceColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Pos)))) |
Construction of Pos
from Int
. The function throws
InvalidPosException
when given a non-positive argument.
Since: megaparsec-6.0.0
initialPos :: FilePath -> SourcePos #
Construct initial position (line 1, column 1) given name of source file.
SourcePos
showSourcePosPair :: (SourcePos, SourcePos) -> String Source #
Render a pair of source position in human-readable form.
showSourcePos :: SourcePos -> String Source #
Render source position in human-readable form.
choice' :: [TextParser m a] -> TextParser m a Source #
Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.
choiceInState :: [StateT s (ParsecT CustomErr Text m) a] -> StateT s (ParsecT CustomErr Text m) a Source #
Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.
surroundedBy :: Applicative m => m openclose -> m a -> m a Source #
runTextParser :: TextParser Identity a -> Text -> Either (ParseErrorBundle Text CustomErr) a Source #
Run a text parser in the identity monad. See also: parseWithState.
rtp :: TextParser Identity a -> Text -> Either (ParseErrorBundle Text CustomErr) a Source #
Run a text parser in the identity monad. See also: parseWithState.
parsewithString :: Parsec e String a -> String -> Either (ParseErrorBundle String e) a Source #
parseWithState :: Monad m => st -> StateT st (ParsecT CustomErr Text m) a -> Text -> m (Either (ParseErrorBundle Text CustomErr) a) Source #
Run a stateful parser with some initial state on a text. See also: runTextParser, runJournalParser.
parseWithState' :: Stream s => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseErrorBundle s e) a Source #
parseerror :: (Show t, Show (Token t), Show e) => ParseErrorBundle t e -> a Source #
showDateParseError :: (Show t, Show (Token t), Show e) => ParseErrorBundle t e -> String Source #
nonspace :: TextParser m Char Source #
isNonNewlineSpace :: Char -> Bool Source #
restofline :: TextParser m String Source #
eolof :: TextParser m () Source #
re-exports
A custom error type for the parser. The type is specialized to
parsers of Text
streams.
Instances
Eq CustomErr Source # | |
Ord CustomErr Source # | |
Show CustomErr Source # | |
ShowErrorComponent CustomErr Source # | |
Defined in Text.Megaparsec.Custom | |
Ord (ParseError Text CustomErr) Source # | |
Defined in Text.Megaparsec.Custom Methods compare :: ParseError Text CustomErr -> ParseError Text CustomErr -> Ordering # (<) :: ParseError Text CustomErr -> ParseError Text CustomErr -> Bool # (<=) :: ParseError Text CustomErr -> ParseError Text CustomErr -> Bool # (>) :: ParseError Text CustomErr -> ParseError Text CustomErr -> Bool # (>=) :: ParseError Text CustomErr -> ParseError Text CustomErr -> Bool # max :: ParseError Text CustomErr -> ParseError Text CustomErr -> ParseError Text CustomErr # min :: ParseError Text CustomErr -> ParseError Text CustomErr -> ParseError Text CustomErr # |