| Copyright | (c) Harley Eades 2026 |
|---|---|
| Maintainer | harley.eades@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Configuration.Cfv.Parser
Description
This module consists of the CFV parser API.
Synopsis
- parseCfvFile :: FilePath -> IO (Either CfvError [Binding])
- parseCfvFileWith :: ShellConfig -> FilePath -> IO (Either CfvError [Binding])
- data CfvError
- data SyntaxError = SyntaxError {}
- data ErrorKind
- data Item
- data Position = Position {}
- parseEvalCfv :: [Char] -> Text -> IO (Either CfvError [Binding])
- parseEvalCfvWith :: ShellConfig -> [Char] -> Text -> IO (Either CfvError [Binding])
- renderCfvError :: CfvError -> Text
Documentation
parseCfvFile :: FilePath -> IO (Either CfvError [Binding]) Source #
Read, parse and evaluate a .cfv file using defaultShellConfig.
Returns the variables in source order; a variable declared more than once
appears more than once (so lookup finds the first declaration). Commands
run one at a time in file order, and the first failure aborts the whole
operation.
Never throws for extension, read, decode, parse or command problems; they are
all returned as CfvError. (To throw instead:
either E.throwIO pure =<< parseCfvFile p.)
parseCfvFileWith :: ShellConfig -> FilePath -> IO (Either CfvError [Binding]) Source #
Like parseCfvFile with an explicit shell configuration.
Everything that can go wrong when processing a CFV file.
Constructors
| InvalidExtension FilePath | The file name does not end in |
| FileReadError FilePath IOException | The file could not be opened or read. |
| FileDecodeError FilePath UnicodeException | The file's contents are not valid UTF-8. |
| FileSyntaxError SyntaxError | The contents do not parse. |
| FileCommandError CommandError Text VarAttr Position | A backtick command could not be run, or failed. (Only produced by functions that run commands.) |
Instances
| Exception CfvError Source # | |
Defined in Configuration.Cfv.Parser Methods toException :: CfvError -> SomeException # fromException :: SomeException -> Maybe CfvError # displayException :: CfvError -> String # | |
| Show CfvError Source # | |
| Eq CfvError Source # | |
data SyntaxError Source #
A problem with the text itself, with a location.
Constructors
| SyntaxError | |
Fields
| |
Instances
| Exception SyntaxError Source # | |
Defined in Configuration.Cfv.Parser Methods toException :: SyntaxError -> SomeException # fromException :: SomeException -> Maybe SyntaxError # displayException :: SyntaxError -> String # | |
| Show SyntaxError Source # | |
Defined in Configuration.Cfv.Parser Methods showsPrec :: Int -> SyntaxError -> ShowS # show :: SyntaxError -> String # showList :: [SyntaxError] -> ShowS # | |
| Eq SyntaxError Source # | |
Defined in Configuration.Cfv.Parser | |
The specific kind of syntax error.
Constructors
| UnexpectedInput (Maybe Item) [Item] | Found this (if known), but expected one of these. |
| ReservedWord Text | A Haskell keyword (or a lone |
| InvalidEscape (Maybe Char) | A backslash followed by a character that is not a known escape.
Position: the backslash. |
| UnterminatedString Char | A string literal with no closing quote (carries the quote character). Position: the opening quote. |
| UnterminatedCommand | A backtick command with no closing backtick. Position: the opening backtick. |
| OtherFailure Text | Anything else; should not occur with the current grammar. |
Something the parser found or expected.
Constructors
| Literal Text | Specific text, such as |
| Description Text | A named construct, such as |
| EndOfFile |
A location in the source. Line and column are 1-based; the offset is the 0-based character offset from the start of the input.
parseEvalCfv :: [Char] -> Text -> IO (Either CfvError [Binding]) Source #
Like parseCfvFile, but doesn't read from a file. Useful for testing.
parseEvalCfvWith :: ShellConfig -> [Char] -> Text -> IO (Either CfvError [Binding]) Source #
Like parseEvalCfv but with an explicit shell configuration.