Copyright | (c) Eric Mertens 2017 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe |
Language | Haskell2010 |
This module is separate from the Lexer.x input to Alex to segregate the automatically generated code from the hand written code. The automatically generated code causes lots of warnings which mask the interesting warnings.
- type AlexInput = Located Text
- alexGetByte :: AlexInput -> Maybe (Word8, AlexInput)
- data LexerMode
- lexerModeInt :: LexerMode -> Int
- type Action = Located Text -> LexerMode -> (LexerMode, [Located Token])
- token :: (Text -> Token) -> Action
- token_ :: Token -> Action
- errorAction :: AlexInput -> [Located Token]
- eofAction :: Position -> LexerMode -> [Located Token]
- integer :: Text -> Token
- double :: Text -> Token
- bareKeyToken :: Text -> Token
- startString :: Int -> Action
- emitChar :: Action
- emitChar' :: Char -> Action
- emitUnicodeChar :: Action
- endString :: Action
- localtime :: Text -> Token
- zonedtime :: Text -> Token
- day :: Text -> Token
- timeofday :: Text -> Token
Alex required definitions
type AlexInput = Located Text Source #
The generated code expects the lexer input type to be named AlexInput
alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) Source #
Get the next characteristic byte from the input source.
Lexer modes
The lexer can be in a normal mode or can be lexing a string literal.
lexerModeInt :: LexerMode -> Int Source #
Compute the Alex state corresponding to a particular LexerMode
Lexer actions
= Located Text | located lexeme |
-> LexerMode | lexer mode |
-> (LexerMode, [Located Token]) | updated lexer mode, emitted tokens |
Type of actions used by lexer upon matching a rule
Helper function for building an Action
using the lexeme
token_ :: Token -> Action Source #
Helper function for building an Action
where the lexeme is unused.
errorAction :: AlexInput -> [Located Token] Source #
Action to perform when lexer gets stuck. Emits an error.
eofAction :: Position -> LexerMode -> [Located Token] Source #
Action to perform upon end of file. Produce errors if EOF was unexpected.
Token parsers
Construct a BareKeyToken
for the given lexeme. This operation
copies the lexeme into a fresh Text
value to ensure that a slice
of the original source file is kept.
String literal actions
startString :: Int -> Action Source #
Enter the string literal lexer
emitUnicodeChar :: Action Source #
Interpret the current lexeme as a unicode escape sequence and add the resulting character to the current string literal.