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.Utils

Description

This module provides a custom engine for the Alex generated lexer. This lexer drive provides nested states, unicode support, and file location tracking.

The various states of this module are needed to deal with the varying lexing rules while lexing values, keys, and string-literals.

Synopsis

Types

type Action = Located String -> State [Context] [Located Token] Source #

Type of actions associated with lexer patterns

data Context Source #

Representation of the current lexer state.

Constructors

ListContext Position

processing an inline list, lex values

TableContext Position

processing an inline table, don't lex values

ValueContext

processing after an equals, lex one value

MlStrContext Position [String]

position of opening delimiter and list of fragments

StrContext Position [String]

position of opening delimiter and list of fragments

Instances

Instances details
Show Context Source # 
Instance details

Defined in Toml.Lexer.Utils

Input processing

locatedUncons :: Located String -> Maybe (Int, Located String) Source #

Pop the first character off a located string if it's not empty. The resulting Int will either be the ASCII value of the character or 1 for non-ASCII Unicode values. To avoid a clash, x1 is remapped to 0.

Actions

value :: (String -> Token) -> Action Source #

Emit a value token using the current lexeme and update the current state

value_ :: Token -> Action Source #

Emit a value token and update the current state

token :: (String -> Token) -> Action Source #

Emit a token using the current lexeme

token_ :: Token -> Action Source #

Emit a token ignoring the current lexeme

squareO :: Action Source #

Record an opening square bracket and update the state

squareC :: Action Source #

Record a closing square bracket and update the state

curlyO :: Action Source #

Record an opening curly bracket and update the state

curlyC :: Action Source #

Record a closing curly bracket and update the state

equals :: Action Source #

Record an = token and update the state

timeValue Source #

Arguments

:: ParseTime a 
=> String

description for error messages

-> [String]

possible valid patterns

-> (a -> Token)

token constructor

-> Action 

Attempt to parse the current lexeme as a date-time token.

eofToken :: [Context] -> Located String -> Located Token Source #

Generate the correct terminating token given the current lexer state.

String literals

strFrag :: Action Source #

Add a literal fragment of a string to the current string state.

startMlStr :: Action Source #

Start a multi-line basic string literal

startStr :: Action Source #

Start a basic string literal

endStr :: Action Source #

End the current string state and emit the string literal token.

unicodeEscape :: Action Source #

Resolve a unicode escape sequence and add it to the current string literal