Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains Dhall's parsing logic
Synopsis
- exprFromText :: String -> Text -> Either ParseError (Expr Src Import)
- exprAndHeaderFromText :: String -> Text -> Either ParseError (Text, Expr Src Import)
- expr :: Parser (Expr Src Import)
- exprA :: Parser a -> Parser (Expr Src a)
- data Src = Src !SourcePos !SourcePos Text
- data SourcedException e = SourcedException Src e
- data ParseError = ParseError {}
- newtype Parser a = Parser {}
Utilities
:: 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 #
:: 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
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
Source code extract
Instances
Eq Src Source # | |
Data Src Source # | |
Defined in Dhall.Parser.Combinators 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 # 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 # | |
Show Src Source # | |
Pretty Src Source # | |
Defined in Dhall.Parser.Combinators |
data SourcedException e Source #
Instances
Show e => Show (SourcedException e) Source # | |
Defined in Dhall.Parser.Combinators showsPrec :: Int -> SourcedException e -> ShowS # show :: SourcedException e -> String # showList :: [SourcedException e] -> ShowS # | |
Exception e => Exception (SourcedException e) Source # | |
Defined in Dhall.Parser.Combinators toException :: SourcedException e -> SomeException # fromException :: SomeException -> Maybe (SourcedException e) # displayException :: SourcedException e -> String # |
data ParseError Source #
A parsing error
Instances
Show ParseError Source # | |
Defined in Dhall.Parser showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |
Exception ParseError Source # | |
Defined in Dhall.Parser toException :: ParseError -> SomeException # fromException :: SomeException -> Maybe ParseError # displayException :: ParseError -> String # |
A Parser
that is almost identical to
Text.Megaparsec.
except treating Haskell-style
comments as whitespaceParsec