Safe Haskell | None |
---|---|
Language | Haskell2010 |
Dhall.Parser
Description
This module contains Dhall's parsing logic
Synopsis
- exprFromText :: String -> Text -> Either ParseError (Expr Src Import)
- exprAndHeaderFromText :: String -> Text -> Either ParseError (Header, Expr Src Import)
- censor :: ParseError -> ParseError
- createHeader :: Text -> Header
- expr :: Parser (Expr Src Import)
- exprA :: Parser a -> Parser (Expr Src a)
- newtype Header = Header Text
- data Src = Src {}
- data SourcedException e = SourcedException Src e
- data ParseError = ParseError {}
- newtype Parser a = Parser {}
Utilities
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 Text
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 (Header, 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 {- Comment -} 2
Then this will preserve Comment 1
, but not Comment 2
This is used by dhall-format
to preserve leading comments and whitespace
censor :: ParseError -> ParseError Source #
Replace the source code with spaces when rendering error messages
This utility is used to implement the --censor
flag
createHeader :: Text -> Header Source #
Create a header with stripped leading spaces and trailing newlines
Parsers
exprA :: Parser a -> Parser (Expr Src a) Source #
Deprecated: Support for parsing custom imports will be dropped in a future release
Parser for a top-level Dhall expression. The expression is parameterized over any parseable type, allowing the language to be extended as needed.
Types
A header corresponds to the leading comment at the top of a Dhall file.
The header includes comment characters but is stripped of leading spaces and trailing newlines
Source code extract
Instances
Data Src Source # | |||||
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 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 :: forall r r'. (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 | |||||
Generic Src Source # | |||||
Defined in Dhall.Src Associated Types
| |||||
Show Src Source # | |||||
NFData Src Source # | |||||
Eq Src Source # | |||||
Ord Src Source # | |||||
Pretty Src Source # | |||||
Defined in Dhall.Src | |||||
Lift Src Source # | |||||
type Rep Src Source # | |||||
Defined in Dhall.Src type Rep Src = D1 ('MetaData "Src" "Dhall.Src" "dhall-1.42.2-JTdjyjj12otJJgEBk3mJ2X" 'False) (C1 ('MetaCons "Src" 'PrefixI 'True) (S1 ('MetaSel ('Just "srcStart") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SourcePos) :*: (S1 ('MetaSel ('Just "srcEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SourcePos) :*: S1 ('MetaSel ('Just "srcText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))) |
data SourcedException e Source #
An exception annotated with a Src
span
Constructors
SourcedException Src e |
Instances
Exception e => Exception (SourcedException e) Source # | |
Defined in Dhall.Parser.Combinators Methods toException :: SourcedException e -> SomeException fromException :: SomeException -> Maybe (SourcedException e) displayException :: SourcedException e -> String | |
Show e => Show (SourcedException e) Source # | |
Defined in Dhall.Parser.Combinators Methods showsPrec :: Int -> SourcedException e -> ShowS show :: SourcedException e -> String showList :: [SourcedException e] -> ShowS |
data ParseError Source #
A parsing error
Constructors
ParseError | |
Instances
Exception ParseError Source # | |
Defined in Dhall.Parser Methods toException :: ParseError -> SomeException fromException :: SomeException -> Maybe ParseError displayException :: ParseError -> String | |
Show ParseError Source # | |
Defined in Dhall.Parser Methods showsPrec :: Int -> ParseError -> ShowS show :: ParseError -> String showList :: [ParseError] -> ShowS |
A Parser
that is almost identical to
Text.Megaparsec.
except treating Haskell-style
comments as whitespaceParsec
Instances
MonadFail Parser Source # | |
Defined in Dhall.Parser.Combinators | |
Alternative Parser Source # | |
Applicative Parser Source # | |
Functor Parser Source # | |
Monad Parser Source # | |
MonadPlus Parser Source # | |
CharParsing Parser Source # | |
Parsing Parser Source # | |
TokenParsing Parser Source # | |
MonadParsec Void Text Parser Source # | |
Defined in Dhall.Parser.Combinators Methods parseError :: ParseError Text Void -> Parser a label :: String -> Parser a -> Parser a hidden :: 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) 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 Void) updateParserState :: (State Text Void -> State Text Void) -> Parser () mkParsec :: (State Text Void -> Reply Void Text a) -> Parser a | |
IsString a => IsString (Parser a) Source # | |
Defined in Dhall.Parser.Combinators Methods fromString :: String -> Parser a | |
(Semigroup a, Monoid a) => Monoid (Parser a) Source # | |
Semigroup a => Semigroup (Parser a) Source # | |