-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parser for the TOML configuration language -- -- Parser for the TOML configuration language. TOML is specified by -- https://github.com/toml-lang/toml. This language is designed to -- be easy to understand and unambiguous. -- -- This implementation uses Alex and Happy to generate an efficient lexer -- and parser. It aims to have minimal library dependencies. @package toml-parser @version 0.1.0.0 module TOML.Value -- | Values possible in a TOML file data Value -- | table, key-value pairs Table :: [(Text, Value)] -> Value -- | array List :: [Value] -> Value -- | floating-point literal Double :: !Double -> Value -- | integer literal Integer :: !Integer -> Value -- | string literal String :: !Text -> Value -- | boolean literal Bool :: Bool -> Value -- | offset date-time ZonedTimeV :: !ZonedTime -> Value -- | local date-time LocalTimeV :: !LocalTime -> Value -- | local date DayV :: !Day -> Value -- | local time TimeOfDayV :: !TimeOfDay -> Value instance GHC.Show.Show TOML.Value.Value instance GHC.Read.Read TOML.Value.Value -- | This module provides the token type used in the lexer and parser and -- provides the extra pass to insert layout tokens. module TOML.Tokens -- | The token type used by Config.Lexer and Config.Parser data Token -- | string literal StringToken :: Text -> Token -- | bare table key BareKeyToken :: Text -> Token -- | integer literal IntegerToken :: Integer -> Token -- | floating -point literal DoubleToken :: Double -> Token -- | offset date-time ZonedTimeToken :: ZonedTime -> Token -- | local date-time LocalTimeToken :: LocalTime -> Token -- | local time TimeOfDayToken :: TimeOfDay -> Token -- | local date DayToken :: Day -> Token -- |
-- , --CommaToken :: Token -- |
-- . --PeriodToken :: Token -- |
-- [ --LeftBracketToken :: Token -- |
-- [ --RightBracketToken :: Token -- |
-- {
--
LeftBraceToken :: Token
-- | -- } --RightBraceToken :: Token -- |
-- = --EqualToken :: Token -- |
-- true --TrueToken :: Token -- |
-- false --FalseToken :: Token -- | lexical error ErrorToken :: LexerError -> Token -- | end-of-file EofToken :: Token -- | Errors possible in the course of lexing data LexerError -- | unterminated string literal UntermString :: LexerError -- | invalid escape sequence BadEscape :: LexerError -- | no matching lexer rule NoMatch :: Char -> LexerError instance GHC.Show.Show TOML.Tokens.Token instance GHC.Read.Read TOML.Tokens.Token instance GHC.Show.Show TOML.Tokens.LexerError instance GHC.Read.Read TOML.Tokens.LexerError module TOML.Located -- | A position in a text file data Position Position :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Position -- | zero-based character index [posIndex] :: Position -> {-# UNPACK #-} !Int -- | one-based line number [posLine] :: Position -> {-# UNPACK #-} !Int -- | one-based column number [posColumn] :: Position -> {-# UNPACK #-} !Int -- | A value annotated with its text file position data Located a Located :: {-# UNPACK #-} !Position -> !a -> Located a -- | position information [locPosition] :: Located a -> {-# UNPACK #-} !Position -- | annotated value [locThing] :: Located a -> !a -- | The initial Position for the start of a file startPos :: Position instance Data.Traversable.Traversable TOML.Located.Located instance Data.Foldable.Foldable TOML.Located.Located instance GHC.Base.Functor TOML.Located.Located instance GHC.Show.Show a => GHC.Show.Show (TOML.Located.Located a) instance GHC.Read.Read a => GHC.Read.Read (TOML.Located.Located a) instance GHC.Show.Show TOML.Located.Position instance GHC.Read.Read TOML.Located.Position -- | 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. module TOML.LexerUtils -- | The generated code expects the lexer input type to be named -- AlexInput type AlexInput = Located Text -- | Get the next characteristic byte from the input source. alexGetByte :: AlexInput -> Maybe (Word8, AlexInput) -- | The lexer can be in a normal mode or can be lexing a string literal. data LexerMode InNormal :: LexerMode -- | alex-mode, starting-position, reversed accumulated characters InString :: !Int -> !Position -> String -> LexerMode -- | Compute the Alex state corresponding to a particular LexerMode lexerModeInt :: LexerMode -> Int -- | Type of actions used by lexer upon matching a rule type Action = Located Text located lexeme -> LexerMode lexer mode -> (LexerMode, [Located Token]) updated lexer mode, emitted tokens -- | Helper function for building an Action using the lexeme token :: (Text -> Token) -> Action -- | Helper function for building an Action where the lexeme is -- unused. token_ :: Token -> Action -- | Action to perform when lexer gets stuck. Emits an error. errorAction :: AlexInput -> [Located Token] -- | Action to perform upon end of file. Produce errors if EOF was -- unexpected. eofAction :: Position -> LexerMode -> [Located Token] -- | Construct a Integer token from a lexeme. integer :: Text -> Token -- | Construct a Double token from a lexeme. double :: Text -> 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. bareKeyToken :: Text -> Token -- | Enter the string literal lexer startString :: Int -> Action -- | Add current lexeme to the current string literal. emitChar :: Action -- | Add literal character to the current string literal. emitChar' :: Char -> Action -- | Interpret the current lexeme as a unicode escape sequence and add the -- resulting character to the current string literal. emitUnicodeChar :: Action -- | Successfully terminate the current mode and emit tokens as needed endString :: Action -- | Date and time lexeme parsers localtime :: Text -> Token -- | Date and time lexeme parsers zonedtime :: Text -> Token -- | Date and time lexeme parsers day :: Text -> Token -- | Date and time lexeme parsers timeofday :: Text -> Token instance GHC.Show.Show TOML.LexerUtils.LexerMode -- | Lexer for TOML generated by Alex. Errors are reported in the resulting -- token list with Error. As much as possible this module only -- contains generated code. The rest of the implementation is in -- LexerUtils. module TOML.Lexer -- | Produce a token stream from an input file. The token stream will -- always be terminated by an ErrorToken or EofToken. scanTokens :: Text -> [Located Token] module TOML.Errors -- | Errors that can occur while loading a TOML file. data TOMLError -- | unexpected token while parser Unexpected :: (Located Token) -> TOMLError -- | unterminated token while parser Unterminated :: (Located Token) -> TOMLError -- | ambiguous table entry OverlappingKey :: [Text] -> TOMLError -- | displayException provides human-readable error message -- | Generates a human-readable description of a token. showToken :: Token -> String -- | Generates a human-readable description of a lexical error. showLexerError :: LexerError -> String instance GHC.Show.Show TOML.Errors.TOMLError instance GHC.Read.Read TOML.Errors.TOMLError instance GHC.Exception.Exception TOML.Errors.TOMLError -- | This module provides an intermediate representation for TOML files. -- The parser produces a list of top-level table components, and this -- module gathers those together in the form of tables and lists of -- tables. module TOML.Components -- | Various top-level elements that can be returned by the TOML parser. data Component -- | key value pairs before any [header] InitialEntry :: [(Text, Value)] -> Component -- | key value pairs after any [header] TableEntry :: Path -> [(Text, Value)] -> Component -- | key value pairs after any [[header]] ArrayEntry :: Path -> [(Text, Value)] -> Component -- | Non-empty list of table keys type Path = [Text] -- | Merge a list of top-level components into a single table, or throw an -- error with an ambiguous path. componentsToTable :: [Component] -> Either Path [(Text, Value)] -- | Collapse the various components generated by the parser into a single -- list of path-value pairs. This operations is particularly responsible -- for gathering top-level array entries together. collapseComponents :: [Component] -> [(Path, Value)] -- | Extract all of the leading ArrayEntry components that match the -- given path. splitArrays :: Path -> [Component] -> ([[(Text, Value)]], [Component]) -- | Given a list of key-value pairs ordered by key, group the list by -- equality on the head of the key-path list. factorHeads :: Eq k => [([k], v)] -> [(k, [([k], v)])] -- | Flatten a list of path-value pairs into a single table. If in the -- course of flattening the pairs if the value at a particular path is -- assigned twice, that path will be returned instead. flattenTableList :: [(Path, Value)] -> Either Path [(Text, Value)] -- | Merge a table into the current list of path-value pairs. The resulting -- list is sorted to make it appropriate for subsequent grouping -- operations. mergeInlineTable :: [(Text, value)] -> [(Path, value)] -> [(Path, value)] -- | Order a list of path-value pairs lexicographically by path. order :: [(Path, value)] -> [(Path, value)] -- | Throw an error with the problematic path if a duplicate is found. validateInlineTables :: Path -> Value -> Either Path () -- | Find an entry that appears in the given list more than once. findDuplicate :: Ord a => [a] -> Maybe a instance GHC.Show.Show TOML.Components.Component instance GHC.Read.Read TOML.Components.Component -- | Parser for TOML generated by Happy. module TOML.Parser -- | Attempt to parse a layout annotated token stream or the token that -- caused the parse to fail. parseComponents :: [Located Token] -> Either TOMLError [Component] -- | Parser for the TOML file format: -- https://github.com/toml-lang/toml module TOML -- | Parse the given TOML file. Returns the top-level table as a list of -- key-value pairs or returns an error. parseTOML :: Text -> Either TOMLError [(Text, Value)] -- | Values possible in a TOML file data Value -- | table, key-value pairs Table :: [(Text, Value)] -> Value -- | array List :: [Value] -> Value -- | floating-point literal Double :: !Double -> Value -- | integer literal Integer :: !Integer -> Value -- | string literal String :: !Text -> Value -- | boolean literal Bool :: Bool -> Value -- | offset date-time ZonedTimeV :: !ZonedTime -> Value -- | local date-time LocalTimeV :: !LocalTime -> Value -- | local date DayV :: !Day -> Value -- | local time TimeOfDayV :: !TimeOfDay -> Value -- | Errors that can occur while loading a TOML file. data TOMLError -- | unexpected token while parser Unexpected :: (Located Token) -> TOMLError -- | unterminated token while parser Unterminated :: (Located Token) -> TOMLError -- | ambiguous table entry OverlappingKey :: [Text] -> TOMLError -- | Errors possible in the course of lexing data LexerError -- | unterminated string literal UntermString :: LexerError -- | invalid escape sequence BadEscape :: LexerError -- | no matching lexer rule NoMatch :: Char -> LexerError -- | A value annotated with its text file position data Located a Located :: {-# UNPACK #-} !Position -> !a -> Located a -- | position information [locPosition] :: Located a -> {-# UNPACK #-} !Position -- | annotated value [locThing] :: Located a -> !a -- | A position in a text file data Position Position :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Position -- | zero-based character index [posIndex] :: Position -> {-# UNPACK #-} !Int -- | one-based line number [posLine] :: Position -> {-# UNPACK #-} !Int -- | one-based column number [posColumn] :: Position -> {-# UNPACK #-} !Int -- | The token type used by Config.Lexer and Config.Parser data Token -- | string literal StringToken :: Text -> Token -- | bare table key BareKeyToken :: Text -> Token -- | integer literal IntegerToken :: Integer -> Token -- | floating -point literal DoubleToken :: Double -> Token -- | offset date-time ZonedTimeToken :: ZonedTime -> Token -- | local date-time LocalTimeToken :: LocalTime -> Token -- | local time TimeOfDayToken :: TimeOfDay -> Token -- | local date DayToken :: Day -> Token -- |
-- , --CommaToken :: Token -- |
-- . --PeriodToken :: Token -- |
-- [ --LeftBracketToken :: Token -- |
-- [ --RightBracketToken :: Token -- |
-- {
--
LeftBraceToken :: Token
-- | -- } --RightBraceToken :: Token -- |
-- = --EqualToken :: Token -- |
-- true --TrueToken :: Token -- |
-- false --FalseToken :: Token -- | lexical error ErrorToken :: LexerError -> Token -- | end-of-file EofToken :: Token