toml-parser-0.1.0.0: Parser for the TOML configuration language

Copyright(c) Eric Mertens 2017
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe
LanguageHaskell2010

TOML.LexerUtils

Contents

Description

This module is separate from the Lexer.x input to Alex to segregate the automatically generated code from the hand written code. The automatically generated code causes lots of warnings which mask the interesting warnings.

Synopsis

Alex required definitions

type AlexInput = Located Text Source #

The generated code expects the lexer input type to be named AlexInput

alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) Source #

Get the next characteristic byte from the input source.

Lexer modes

data LexerMode Source #

The lexer can be in a normal mode or can be lexing a string literal.

Constructors

InNormal 
InString !Int !Position String

alex-mode, starting-position, reversed accumulated characters

lexerModeInt :: LexerMode -> Int Source #

Compute the Alex state corresponding to a particular LexerMode

Lexer actions

type Action Source #

Arguments

 = Located Text

located lexeme

-> LexerMode

lexer mode

-> (LexerMode, [Located Token])

updated lexer mode, emitted tokens

Type of actions used by lexer upon matching a rule

token Source #

Arguments

:: (Text -> Token)

lexeme -> token

-> Action 

Helper function for building an Action using the lexeme

token_ :: Token -> Action Source #

Helper function for building an Action where the lexeme is unused.

errorAction :: AlexInput -> [Located Token] Source #

Action to perform when lexer gets stuck. Emits an error.

eofAction :: Position -> LexerMode -> [Located Token] Source #

Action to perform upon end of file. Produce errors if EOF was unexpected.

Token parsers

integer Source #

Arguments

:: Text

lexeme

-> Token 

Construct a Integer token from a lexeme.

double Source #

Arguments

:: Text

lexeme

-> Token 

Construct a Double token from a lexeme.

bareKeyToken Source #

Arguments

:: Text

lexeme

-> Token 

Construct a BareKeyToken for the given lexeme. This operation copies the lexeme into a fresh Text value to ensure that a slice of the original source file is kept.

String literal actions

startString :: Int -> Action Source #

Enter the string literal lexer

emitChar :: Action Source #

Add current lexeme to the current string literal.

emitChar' :: Char -> Action Source #

Add literal character to the current string literal.

emitUnicodeChar :: Action Source #

Interpret the current lexeme as a unicode escape sequence and add the resulting character to the current string literal.

endString :: Action Source #

Successfully terminate the current mode and emit tokens as needed

Date/time token parsers

localtime :: Text -> Token Source #

Date and time lexeme parsers

zonedtime :: Text -> Token Source #

Date and time lexeme parsers

day :: Text -> Token Source #

Date and time lexeme parsers

timeofday :: Text -> Token Source #

Date and time lexeme parsers