| Copyright | (c) Eric Mertens 2023 | 
|---|---|
| License | ISC | 
| Maintainer | emertens@gmail.com | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
Toml.Lexer
Description
This module parses a TOML file into a lazy sequence of tokens. The lexer is aware of nested brackets and equals signs in order to handle TOML's context-sensitive lexing requirements. This context enables the lexer to distinguish between bare keys and various values like: floating-point literals, integer literals, and date literals.
This module uses actions and lexical hooks defined in LexerUtils.
Synopsis
- data Context
- scanToken :: Context -> Located String -> Either (Located String) (Located Token, Located String)
- lexValue :: String -> Either String Token
- data Token- = TokTrue
- | TokFalse
- | TokComma
- | TokEquals
- | TokNewline
- | TokPeriod
- | TokSquareO
- | TokSquareC
- | Tok2SquareO
- | Tok2SquareC
- | TokCurlyO
- | TokCurlyC
- | TokBareKey String
- | TokString String
- | TokMlString String
- | TokInteger !Integer
- | TokFloat !Double
- | TokOffsetDateTime !ZonedTime
- | TokLocalDateTime !LocalTime
- | TokLocalDate !Day
- | TokLocalTime !TimeOfDay
- | TokEOF
 
Documentation
Representation of the current lexer state.
Constructors
| TopContext | top-level where  | 
| TableContext | inline table - lex key names | 
| ValueContext | value lexer - lex number literals | 
| MlBstrContext Position [String] | multiline basic string: position of opening delimiter and list of fragments | 
| BstrContext Position [String] | basic string: position of opening delimiter and list of fragments | 
| MlLstrContext Position [String] | multiline literal string: position of opening delimiter and list of fragments | 
| LstrContext Position [String] | literal string: position of opening delimiter and list of fragments | 
scanToken :: Context -> Located String -> Either (Located String) (Located Token, Located String) Source #
Get the next token from a located string. This function can be total because one of the possible token outputs is an error token.
lexValue :: String -> Either String Token Source #
Lex a single token in a value context. This is mostly useful for testing.
Lexical token
Constructors
| TokTrue | true | 
| TokFalse | false | 
| TokComma | ',' | 
| TokEquals | '=' | 
| TokNewline | end-of-line | 
| TokPeriod |  | 
| TokSquareO | '[' | 
| TokSquareC | ']' | 
| Tok2SquareO | '[[' | 
| Tok2SquareC | ']]' | 
| TokCurlyO | '{' | 
| TokCurlyC | '}' | 
| TokBareKey String | bare key | 
| TokString String | string literal | 
| TokMlString String | multiline string literal | 
| TokInteger !Integer | integer literal | 
| TokFloat !Double | floating-point literal | 
| TokOffsetDateTime !ZonedTime | date-time with timezone offset | 
| TokLocalDateTime !LocalTime | local date-time | 
| TokLocalDate !Day | local date | 
| TokLocalTime !TimeOfDay | local time | 
| TokEOF | end-of-input |