Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Common parsers. See Text.Megaparsec.Char.Lexer.
Synopsis
- data TextLabel
- class EmbedTextLabel l where
- embedTextLabel :: TextLabel -> l
- data CompoundTextLabel l
- sepByParser :: (Chunked seq elem, Monad m) => ParserT l s e m elem -> ParserT l s e m () -> ParserT l s e m seq
- betweenParser :: Monad m => ParserT l s e m () -> ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a
- lexemeParser :: Monad m => ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a
- newlineParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m ()
- spaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m ()
- hspaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m ()
- spaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m ()
- hspaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m ()
- decimalParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m, Num a) => ParserT l s e m a
- signedNumStartPred :: Char -> Bool
- scientificParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m Scientific
- numParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Either Integer Scientific)
- data Sign
- signParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Maybe Sign)
- applySign :: Num a => Maybe Sign -> a -> a
- signedParser :: (Stream s, Token s ~ Char, Monad m, Num a) => ParserT l s e m () -> ParserT l s e m a -> ParserT l s e m a
- escapedStringParser :: (Stream s, Token s ~ Char, Monad m) => Char -> ParserT l s e m (Chunk s)
- spanParser :: (PosStream s, Monad m) => (Span (Pos s) -> a -> b) -> ParserT l s e m a -> ParserT l s e m b
- getStreamPos :: (PosStream s, Monad m) => ParserT l s e m (Pos s)
Documentation
Enumeration of common labels in textual parsing.
Instances
Show TextLabel Source # | |
Eq TextLabel Source # | |
EmbedTextLabel TextLabel Source # | |
Defined in SimpleParser.Common embedTextLabel :: TextLabel -> TextLabel Source # | |
ExplainLabel TextLabel Source # | |
Defined in SimpleParser.Explain explainLabel :: TextLabel -> Builder Source # explainLabelText :: TextLabel -> Text Source # |
class EmbedTextLabel l where Source #
embedTextLabel :: TextLabel -> l Source #
Instances
EmbedTextLabel TextLabel Source # | |
Defined in SimpleParser.Common embedTextLabel :: TextLabel -> TextLabel Source # | |
EmbedTextLabel AstLabel Source # | |
Defined in SimpleParser.Examples.Direct.Ast embedTextLabel :: TextLabel -> AstLabel Source # | |
EmbedTextLabel SexpLabel Source # | |
Defined in SimpleParser.Examples.Direct.Sexp embedTextLabel :: TextLabel -> SexpLabel Source # | |
EmbedTextLabel SexpTokLabel Source # | |
Defined in SimpleParser.Examples.Lexed.Sexp | |
EmbedTextLabel (CompoundTextLabel l) Source # | |
Defined in SimpleParser.Common embedTextLabel :: TextLabel -> CompoundTextLabel l Source # |
data CompoundTextLabel l Source #
Union of text and custom labels
Instances
:: (Chunked seq elem, Monad m) | |
=> ParserT l s e m elem | How to parse item |
-> ParserT l s e m () | How to parse separator |
-> ParserT l s e m seq |
Yields the maximal list of separated items. May return an empty list.
:: Monad m | |
=> ParserT l s e m () | How to parse start |
-> ParserT l s e m () | How to parse end |
-> ParserT l s e m a | How to parse inside |
-> ParserT l s e m a |
Parses between start and end markers.
:: Monad m | |
=> ParserT l s e m () | How to consume white space after lexeme |
-> ParserT l s e m a | How to parse actual lexeme |
-> ParserT l s e m a |
A wrapper for lexemes (equivalent to Megaparsec's lexeme
).
newlineParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () Source #
Consumes a newline character.
spaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () Source #
Consumes 0 or more space characters.
hspaceParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m () Source #
Consumes 0 or more non-line-break space characters
spaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m () Source #
Consumes 1 or more space characters.
hspaceParser1 :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m () Source #
Consumes 1 or more non-line-break space characters
decimalParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m, Num a) => ParserT l s e m a Source #
Parses an integer in decimal representation (equivalent to Megaparsec's decimal
).
signedNumStartPred :: Char -> Bool Source #
Predicate for satisfying the start of signed numbers
scientificParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m Scientific Source #
Parses a floating point value as a Scientific
number (equivalent to Megaparsec's scientific
).
numParser :: (EmbedTextLabel l, Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Either Integer Scientific) Source #
Parses a number as a literal integer or a Scientific
number.
Though Scientific
can represent integers, this allows you to distinugish integer literals from scientific literals
since that information is lost after parsing.
signParser :: (Stream s, Token s ~ Char, Monad m) => ParserT l s e m (Maybe Sign) Source #
Consumes an optional + or - representing the sign of a number.
applySign :: Num a => Maybe Sign -> a -> a Source #
Optionally negate the number according to the sign (treating Nothing
as positive sign).
:: (Stream s, Token s ~ Char, Monad m, Num a) | |
=> ParserT l s e m () | How to consume white space after the sign |
-> ParserT l s e m a | How to parse the number itself |
-> ParserT l s e m a | Parser for signed numbers |
Parses an optional sign character followed by a number and yields a correctly-signed
number (equivalend to Megaparsec's signed
).
escapedStringParser :: (Stream s, Token s ~ Char, Monad m) => Char -> ParserT l s e m (Chunk s) Source #
Given a quote charcter (like a single or double quote), yields the contents of the string bounded by those quotes. The contents may contain backslash-escaped quotes. Returns nothing if outside quotes are missing or the stream ends before unquote.