dhall-1.24.0: A configuration language guaranteed to terminate

Safe HaskellNone
LanguageHaskell2010

Dhall.Parser

Contents

Description

This module contains Dhall's parsing logic

Synopsis

Utilities

exprFromText Source #

Arguments

:: String

User-friendly name describing the input expression, used in parsing error messages

-> Text

Input expression to parse

-> Either ParseError (Expr Src Import) 

Parse an expression from Expr containing a Dhall program

exprAndHeaderFromText Source #

Arguments

:: String

User-friendly name describing the input expression, used in parsing error messages

-> Text

Input expression to parse

-> Either ParseError (Text, Expr Src Import) 

Like exprFromText but also returns the leading comments and whitespace (i.e. header) up to the last newline before the code begins

In other words, if you have a Dhall file of the form:

-- Comment 1
 2

Then this will preserve Comment 1, but not Comment 2

This is used by dhall-format to preserve leading comments and whitespace

Parsers

expr :: Parser (Expr Src Import) Source #

Parser for a top-level Dhall expression

exprA :: Parser a -> Parser (Expr Src a) Source #

Parser for a top-level Dhall expression. The expression is parameterized over any parseable type, allowing the language to be extended as needed.

Types

data Src Source #

Source code extract

Constructors

Src !SourcePos !SourcePos Text 
Instances
Eq Src Source # 
Instance details

Defined in Dhall.Src

Methods

(==) :: Src -> Src -> Bool

(/=) :: Src -> Src -> Bool

Data Src Source # 
Instance details

Defined in Dhall.Src

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Src -> c Src

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Src

toConstr :: Src -> Constr

dataTypeOf :: Src -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Src)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Src)

gmapT :: (forall b. Data b => b -> b) -> Src -> Src

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Src -> r

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Src -> r

gmapQ :: (forall d. Data d => d -> u) -> Src -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> Src -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Src -> m Src

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Src -> m Src

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Src -> m Src

Ord Src Source # 
Instance details

Defined in Dhall.Src

Methods

compare :: Src -> Src -> Ordering

(<) :: Src -> Src -> Bool

(<=) :: Src -> Src -> Bool

(>) :: Src -> Src -> Bool

(>=) :: Src -> Src -> Bool

max :: Src -> Src -> Src

min :: Src -> Src -> Src

Show Src Source # 
Instance details

Defined in Dhall.Src

Methods

showsPrec :: Int -> Src -> ShowS

show :: Src -> String

showList :: [Src] -> ShowS

Generic Src Source # 
Instance details

Defined in Dhall.Src

Associated Types

type Rep Src :: Type -> Type

Methods

from :: Src -> Rep Src x

to :: Rep Src x -> Src

Pretty Src Source # 
Instance details

Defined in Dhall.Src

Methods

pretty :: Src -> Doc ann

prettyList :: [Src] -> Doc ann

type Rep Src Source # 
Instance details

Defined in Dhall.Src

type Rep Src = D1 (MetaData "Src" "Dhall.Src" "dhall-1.24.0-1BXKhnS5K26F45u3nGmAoE" False) (C1 (MetaCons "Src" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SourcePos) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 SourcePos) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))))

data SourcedException e Source #

Constructors

SourcedException Src e 
Instances
Show e => Show (SourcedException e) Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

showsPrec :: Int -> SourcedException e -> ShowS

show :: SourcedException e -> String

showList :: [SourcedException e] -> ShowS

Exception e => Exception (SourcedException e) Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

toException :: SourcedException e -> SomeException

fromException :: SomeException -> Maybe (SourcedException e)

displayException :: SourcedException e -> String

data ParseError Source #

A parsing error

Constructors

ParseError 

Fields

Instances
Show ParseError Source # 
Instance details

Defined in Dhall.Parser

Methods

showsPrec :: Int -> ParseError -> ShowS

show :: ParseError -> String

showList :: [ParseError] -> ShowS

Exception ParseError Source # 
Instance details

Defined in Dhall.Parser

Methods

toException :: ParseError -> SomeException

fromException :: SomeException -> Maybe ParseError

displayException :: ParseError -> String

newtype Parser a Source #

A Parser that is almost identical to Text.Megaparsec.Parsec except treating Haskell-style comments as whitespace

Constructors

Parser 

Fields

Instances
Monad Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b

(>>) :: Parser a -> Parser b -> Parser b

return :: a -> Parser a

fail :: String -> Parser a

Functor Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

fmap :: (a -> b) -> Parser a -> Parser b

(<$) :: a -> Parser b -> Parser a

MonadFail Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

fail :: String -> Parser a

Applicative Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

pure :: a -> Parser a

(<*>) :: Parser (a -> b) -> Parser a -> Parser b

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c

(*>) :: Parser a -> Parser b -> Parser b

(<*) :: Parser a -> Parser b -> Parser a

MonadPlus Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

mzero :: Parser a

mplus :: Parser a -> Parser a -> Parser a

Alternative Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

empty :: Parser a

(<|>) :: Parser a -> Parser a -> Parser a

some :: Parser a -> Parser [a]

many :: Parser a -> Parser [a]

Parsing Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

try :: Parser a -> Parser a

(<?>) :: Parser a -> String -> Parser a

skipMany :: Parser a -> Parser ()

skipSome :: Parser a -> Parser ()

unexpected :: String -> Parser a

eof :: Parser ()

notFollowedBy :: Show a => Parser a -> Parser ()

TokenParsing Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

someSpace :: Parser ()

nesting :: Parser a -> Parser a

semi :: Parser Char

highlight :: Highlight -> Parser a -> Parser a

token :: Parser a -> Parser a

CharParsing Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

satisfy :: (Char -> Bool) -> Parser Char

char :: Char -> Parser Char

notChar :: Char -> Parser Char

anyChar :: Parser Char

string :: String -> Parser String

text :: Text -> Parser Text

MonadParsec Void Text Parser Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

failure :: Maybe (ErrorItem (Token Text)) -> Set (ErrorItem (Token Text)) -> Parser a

fancyFailure :: Set (ErrorFancy Void) -> Parser a

label :: String -> Parser a -> Parser a

hidden :: Parser a -> Parser a

try :: Parser a -> Parser a

lookAhead :: Parser a -> Parser a

notFollowedBy :: Parser a -> Parser ()

withRecovery :: (ParseError Text Void -> Parser a) -> Parser a -> Parser a

observing :: Parser a -> Parser (Either (ParseError Text Void) a)

eof :: Parser ()

token :: (Token Text -> Maybe a) -> Set (ErrorItem (Token Text)) -> Parser a

tokens :: (Tokens Text -> Tokens Text -> Bool) -> Tokens Text -> Parser (Tokens Text)

takeWhileP :: Maybe String -> (Token Text -> Bool) -> Parser (Tokens Text)

takeWhile1P :: Maybe String -> (Token Text -> Bool) -> Parser (Tokens Text)

takeP :: Maybe String -> Int -> Parser (Tokens Text)

getParserState :: Parser (State Text)

updateParserState :: (State Text -> State Text) -> Parser ()

IsString a => IsString (Parser a) Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

fromString :: String -> Parser a

Semigroup a => Semigroup (Parser a) Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

(<>) :: Parser a -> Parser a -> Parser a

sconcat :: NonEmpty (Parser a) -> Parser a

stimes :: Integral b => b -> Parser a -> Parser a

(Semigroup a, Monoid a) => Monoid (Parser a) Source # 
Instance details

Defined in Dhall.Parser.Combinators

Methods

mempty :: Parser a

mappend :: Parser a -> Parser a -> Parser a

mconcat :: [Parser a] -> Parser a