Agda-2.2.10: A dependently typed functional programming language and proof assistantSource codeContentsIndex
Agda.Syntax.Parser.Alex
Contents
Alex requirements
Lex actions
Monad operations
Description
This module defines the things required by Alex and some other Alex related things.
Synopsis
data AlexInput = AlexInput {
lexPos :: !Position
lexInput :: String
lexPrevChar :: !Char
}
alexInputPrevChar :: AlexInput -> Char
alexGetChar :: AlexInput -> Maybe (Char, AlexInput)
type LexAction r = PreviousInput -> CurrentInput -> TokenLength -> Parser r
type LexPredicate = ([LexState], ParseFlags) -> PreviousInput -> TokenLength -> CurrentInput -> Bool
(.&&.) :: LexPredicate -> LexPredicate -> LexPredicate
(.||.) :: LexPredicate -> LexPredicate -> LexPredicate
not' :: LexPredicate -> LexPredicate
type PreviousInput = AlexInput
type CurrentInput = AlexInput
type TokenLength = Int
getLexInput :: Parser AlexInput
setLexInput :: AlexInput -> Parser ()
Alex requirements
data AlexInput Source
This is what the lexer manipulates.
Constructors
AlexInput
lexPos :: !Positioncurrent position
lexInput :: Stringcurrent input
lexPrevChar :: !Charpreviously read character
alexInputPrevChar :: AlexInput -> CharSource
Get the previously lexed character. Same as lexPrevChar. Alex needs this to be defined to handle "patterns with a left-context".
alexGetChar :: AlexInput -> Maybe (Char, AlexInput)Source
Lex a character. No surprises.
Lex actions
type LexAction r = PreviousInput -> CurrentInput -> TokenLength -> Parser rSource
In the lexer, regular expressions are associated with lex actions who's task it is to construct the tokens.
type LexPredicate = ([LexState], ParseFlags) -> PreviousInput -> TokenLength -> CurrentInput -> BoolSource
Sometimes regular expressions aren't enough. Alex provides a way to do arbitrary computations to see if the input matches. This is done with a lex predicate.
(.&&.) :: LexPredicate -> LexPredicate -> LexPredicateSource
Conjunction of LexPredicates.
(.||.) :: LexPredicate -> LexPredicate -> LexPredicateSource
Disjunction of LexPredicates.
not' :: LexPredicate -> LexPredicateSource
Negation of LexPredicates.
type PreviousInput = AlexInputSource
type CurrentInput = AlexInputSource
type TokenLength = IntSource
Monad operations
getLexInput :: Parser AlexInputSource
setLexInput :: AlexInput -> Parser ()Source
Produced by Haddock version 2.6.1