Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- Parser
- Parsing locations
- Parsing brackets
- Parsing lists
Synopsis
- (<+>) :: Eq token => Parser' token t -> Parser' token t -> Parser' token t
- data Parse_error' token = Parse_error Line_and_char (Set String) (Maybe token)
- data Parser' token t
- add_location :: Parser' token t -> Parser' token (L t)
- parse :: Eq token => (Char -> char) -> (char -> Line_and_char -> Line_and_char) -> Tokeniser' char token err () -> Parser' token t -> (Parse_error' token -> err) -> String -> Either Error (Either err t)
- parse_brackets :: Parser' token () -> Parser' token () -> Parser' token t -> Parser' token t
- parse_empty_list :: Parser' token [t]
- parse_line_and_char :: Parser' token Line_and_char
- parse_list :: Eq token => Parser' token () -> Parser' token t -> Parser' token [t]
- parse_many :: Eq token => Parser' token t -> Parser' token [t]
- parse_non_empty_list :: Eq token => Parser' token () -> Parser' token t -> Parser' token [t]
- parse_some :: Eq token => Parser' token t -> Parser' token [t]
- parse_token :: Eq token => token -> String -> Parser' token ()
- parse_token' :: Eq token => (token -> Maybe t) -> String -> Parser' token t
Documentation
(<+>) :: Eq token => Parser' token t -> Parser' token t -> Parser' token t infixr 3 Source #
Symmetric choice between two parsers that selects the longest match. Note that if both parsers successfully reach the same location it will result in an ambiguity error that, unlike a normal parse error, is not recoverable by backtracking. Also note that while this operator is normally associative it is not when ambiguity errors are involved.
data Parse_error' token Source #
The types of tokens that were expected at a certain location and the token that was actually found instead (or Nothing
if the end of file was reached unexpectedly).
Parse_error Line_and_char (Set String) (Maybe token) |
Instances
Show token => Show (Parse_error' token) Source # | |
Defined in Parser.Parser showsPrec :: Int -> Parse_error' token -> ShowS # show :: Parse_error' token -> String # showList :: [Parse_error' token] -> ShowS # |
A parser that works with any kind of tokens.
Instances
Monad (Parser' token) Source # | |
Functor (Parser' token) Source # | |
Applicative (Parser' token) Source # | |
Defined in Parser.Parser pure :: a -> Parser' token a # (<*>) :: Parser' token (a -> b) -> Parser' token a -> Parser' token b # liftA2 :: (a -> b -> c) -> Parser' token a -> Parser' token b -> Parser' token c # (*>) :: Parser' token a -> Parser' token b -> Parser' token b # (<*) :: Parser' token a -> Parser' token b -> Parser' token a # |
add_location :: Parser' token t -> Parser' token (L t) Source #
Parse something with an added location from the first token.
parse :: Eq token => (Char -> char) -> (char -> Line_and_char -> Line_and_char) -> Tokeniser' char token err () -> Parser' token t -> (Parse_error' token -> err) -> String -> Either Error (Either err t) Source #
Parse the text. You have to provide a function that classifies characters, a function that tells how to update the location depending on the character, a tokeniser, a parser and a function that converts parse errors to your preferred type.
parse_brackets :: Parser' token () -> Parser' token () -> Parser' token t -> Parser' token t Source #
Parse a term in brackets.
parse_empty_list :: Parser' token [t] Source #
Returns an empty list.
parse_line_and_char :: Parser' token Line_and_char Source #
Get the current location.
parse_list :: Eq token => Parser' token () -> Parser' token t -> Parser' token [t] Source #
Parse a (possibly empty) list with separators.
parse_many :: Eq token => Parser' token t -> Parser' token [t] Source #
Parse a (possibly empty) list without separators.
parse_non_empty_list :: Eq token => Parser' token () -> Parser' token t -> Parser' token [t] Source #
Parse a non-empty list with separators.
parse_some :: Eq token => Parser' token t -> Parser' token [t] Source #
Parse a non-empty list without separators.
parse_token :: Eq token => token -> String -> Parser' token () Source #
Parse a certain token (for example, a delimiter or a keyword) without returning any results. You also have to provide a string that briefly describes the kind of token that is expected - it is used to provide detailed parse errors.
parse_token' :: Eq token => (token -> Maybe t) -> String -> Parser' token t Source #
Parses tokens that fit a certain pattern and transforms them into something more useful - for example, a string or an integer. You also have to provide a string that briefly describes the kind of token that is expected - it is used to provide detailed parse errors.