| Copyright | (c) Eric Mertens 2017 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | Safe |
| Language | Haskell2010 |
TOML
Contents
Description
Parser for the TOML file format: https://github.com/toml-lang/toml
- parseTOML :: Text -> Either TOMLError [(Text, Value)]
- data Value
- data TOMLError
- = Unexpected (Located Token)
- | Unterminated (Located Token)
- | OverlappingKey [Text]
- data LexerError
- data Located a = Located {
- locPosition :: !Position
- locThing :: !a
- data Position = Position {}
- data Token
- = StringToken Text
- | BareKeyToken Text
- | IntegerToken Integer
- | DoubleToken Double
- | ZonedTimeToken ZonedTime
- | LocalTimeToken LocalTime
- | TimeOfDayToken TimeOfDay
- | DayToken Day
- | CommaToken
- | PeriodToken
- | LeftBracketToken
- | RightBracketToken
- | LeftBraceToken
- | RightBraceToken
- | EqualToken
- | TrueToken
- | FalseToken
- | ErrorToken LexerError
- | EofToken
Parsing
parseTOML :: Text -> Either TOMLError [(Text, Value)] Source #
Parse the given TOML file. Returns the top-level table as a list of key-value pairs or returns an error.
Values
Values possible in a TOML file
Constructors
| Table [(Text, Value)] | table, key-value pairs |
| List [Value] | array |
| Double !Double | floating-point literal |
| Integer !Integer | integer literal |
| String !Text | string literal |
| Bool Bool | boolean literal |
| ZonedTimeV !ZonedTime | offset date-time |
| LocalTimeV !LocalTime | local date-time |
| DayV !Day | local date |
| TimeOfDayV !TimeOfDay | local time |
Error information
Errors that can occur while loading a TOML file.
Constructors
| Unexpected (Located Token) | unexpected token while parser |
| Unterminated (Located Token) | unterminated token while parser |
| OverlappingKey [Text] | ambiguous table entry |
data LexerError Source #
Errors possible in the course of lexing
Constructors
| UntermString | unterminated string literal |
| BadEscape | invalid escape sequence |
| NoMatch Char | no matching lexer rule |
Instances
A value annotated with its text file position
Constructors
| Located | |
Fields
| |
A position in a text file
Constructors
| Position | |
The token type used by Config.Lexer and Config.Parser
Constructors
| StringToken Text | string literal |
| BareKeyToken Text | bare table key |
| IntegerToken Integer | integer literal |
| DoubleToken Double | floating -point literal |
| ZonedTimeToken ZonedTime | offset date-time |
| LocalTimeToken LocalTime | local date-time |
| TimeOfDayToken TimeOfDay | local time |
| DayToken Day | local date |
| CommaToken | , |
| PeriodToken | . |
| LeftBracketToken | [ |
| RightBracketToken | [ |
| LeftBraceToken | { |
| RightBraceToken | } |
| EqualToken | = |
| TrueToken | true |
| FalseToken | false |
| ErrorToken LexerError | lexical error |
| EofToken | end-of-file |