| Copyright | (c) Eric Mertens 2024 |
|---|---|
| License | ISC |
| Maintainer | emertens@gmail.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Toml.Syntax
Description
These are the low-level processing functions for transforming concrete TOML syntax into abstract TOML syntax. This module does not do any semantic validation of the parsed TOML.
Synopsis
- parseRawToml :: Text -> Either (Located String) [Expr Position]
- type Key a = NonEmpty (a, Text)
- data Expr a
- = KeyValExpr (Key a) (Val a)
- | TableExpr (Key a)
- | ArrayTableExpr (Key a)
- data Val a
- scanToken :: Context -> Located Text -> Either (Located String) (Located Token, Located Text)
- data Context
- data Token
- = TokTrue
- | TokFalse
- | TokComma
- | TokEquals
- | TokNewline
- | TokPeriod
- | TokSquareO
- | TokSquareC
- | Tok2SquareO
- | Tok2SquareC
- | TokCurlyO
- | TokCurlyC
- | TokBareKey Text
- | TokString Text
- | TokMlString Text
- | TokInteger !Integer
- | TokFloat !Double
- | TokOffsetDateTime !ZonedTime
- | TokLocalDateTime !LocalTime
- | TokLocalDate !Day
- | TokLocalTime !TimeOfDay
- | TokEOF
- data Located a = Located {
- locPosition :: !Position
- locThing :: !a
- data Position = Position {}
- startPos :: Position
Parsing
parseRawToml :: Text -> Either (Located String) [Expr Position] #
Parse a list of tokens either returning the first unexpected token or a list of the TOML statements in the file to be processed by Toml.Semantics.
Headers and assignments corresponding to lines of a TOML file
Constructors
| KeyValExpr (Key a) (Val a) | key value assignment: |
| TableExpr (Key a) | table: |
| ArrayTableExpr (Key a) | array of tables: |
Unvalidated TOML values. Table are represented as a list of assignments rather than as resolved maps.
Constructors
| ValInteger a Integer | |
| ValFloat a Double | |
| ValArray a [Val a] | |
| ValTable a [(Key a, Val a)] | |
| ValBool a Bool | |
| ValString a Text | |
| ValTimeOfDay a TimeOfDay | |
| ValZonedTime a ZonedTime | |
| ValLocalTime a LocalTime | |
| ValDay a Day |
Lexing
scanToken :: Context -> Located Text -> Either (Located String) (Located Token, Located Text) #
Get the next token from a located string or a located error message.
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 [Text] | multiline basic string: position of opening delimiter and list of fragments |
| BstrContext Position [Text] | basic string: position of opening delimiter and list of fragments |
| MlLstrContext Position [Text] | multiline literal string: position of opening delimiter and list of fragments |
| LstrContext Position [Text] | literal string: position of opening delimiter and list of fragments |
Lexical token
Constructors
| TokTrue | true |
| TokFalse | false |
| TokComma | ',' |
| TokEquals | '=' |
| TokNewline | end-of-line |
| TokPeriod | |
| TokSquareO | '[' |
| TokSquareC | ']' |
| Tok2SquareO | '[[' |
| Tok2SquareC | ']]' |
| TokCurlyO | '{' |
| TokCurlyC | '}' |
| TokBareKey Text | bare key |
| TokString Text | string literal |
| TokMlString Text | 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 |
Locations
A value annotated with its text file position
Constructors
| Located | |
Fields
| |
Instances
| Functor Located # | Default instance |
| Foldable Located # | Default instance |
Defined in Toml.Syntax.Position Methods fold :: Monoid m => Located m -> m # foldMap :: Monoid m => (a -> m) -> Located a -> m # foldMap' :: Monoid m => (a -> m) -> Located a -> m # foldr :: (a -> b -> b) -> b -> Located a -> b # foldr' :: (a -> b -> b) -> b -> Located a -> b # foldl :: (b -> a -> b) -> b -> Located a -> b # foldl' :: (b -> a -> b) -> b -> Located a -> b # foldr1 :: (a -> a -> a) -> Located a -> a # foldl1 :: (a -> a -> a) -> Located a -> a # elem :: Eq a => a -> Located a -> Bool # maximum :: Ord a => Located a -> a # minimum :: Ord a => Located a -> a # | |
| Traversable Located # | Default instance |
| Read a => Read (Located a) # | Default instance |
| Show a => Show (Located a) # | Default instance |