toml-parser-1.1.0.0: TOML 1.0.0 parser
Copyright(c) Eric Mertens 2023
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

scanTokens :: String -> [Located Token] Source #

Generate a lazy-list of tokens from the input string. The token stream is guaranteed to be terminated either with TokEOF or TokError.

lexValue :: String -> Token Source #

Lex a single token in a value context. This is mostly useful for testing.

data Token Source #

Lexical token

Constructors

TokTrue
true
TokFalse
false
TokComma
','
TokEquals
'='
TokNewline
'\n'
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

TokError String

lexical error

TokEOF

end of file

Instances

Instances details
Read Token Source # 
Instance details

Defined in Toml.Lexer.Token

Show Token Source # 
Instance details

Defined in Toml.Lexer.Token

Methods

showsPrec :: Int -> Token -> ShowS #

show :: Token -> String #

showList :: [Token] -> ShowS #