jl-0.1.0: Functional sed for JSON
Safe HaskellNone
LanguageHaskell2010

JL.Tokenizer

Description

Duet syntax tokenizer.

Synopsis

Documentation

ellipsis :: Int -> [Char] -> [Char] Source #

specialParsing :: (t1 -> t) -> Parser t1 -> String -> Parser (t, Location) Source #

atom :: t -> String -> Parser (t, Location) Source #

parsing :: (Text -> t) -> Parser Text -> String -> Parser (t, Location) Source #

satisfyToken :: (Token -> Bool) -> TokenParser (Token, Location) Source #

Consume the given predicate from the token stream.

anyToken :: TokenParser (Token, Location) Source #

The parser anyToken accepts any kind of token. It is for example used to implement eof. Returns the accepted token.

consumeToken :: (Token -> Maybe a) -> TokenParser (a, Location) Source #

Consume the given predicate from the token stream.

tokenString :: (Token, Location) -> [Char] Source #

Make a string out of the token, for error message purposes.

tokenPosition :: SourcePos -> (Token, Location) -> t -> SourcePos Source #

Update the position by the token.

type TokenParser e = forall s m. Stream s m (Token, Location) => ParsecT s Int m e Source #

notFollowedBy' :: TokenParser (Token, Location) -> TokenParser () Source #

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 (do{ string "let"
                      ; notFollowedBy alphaNum
                      })

endOfTokens :: TokenParser () Source #

This parser only succeeds at the end of the input. This is not a primitive parser but it is defined using notFollowedBy.

 eof  = notFollowedBy anyToken <?> "end of input"