Copyright | (c) Eric Mertens 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe |
Language | Haskell2010 |
This module is able to parse commands with inline variables and then to evaluate those variables to produce a complete command that varies by the current context.
- data ExpansionChunk
- parseExpansion :: Text -> Maybe [ExpansionChunk]
- resolveMacroExpansions :: (Text -> Maybe Text) -> (Integer -> Maybe Text) -> [ExpansionChunk] -> Maybe Text
- data Macro = Macro {
- macroSpec :: MacroSpec
- macroCommands :: [[ExpansionChunk]]
- data MacroSpec where
- MacroSpec :: ArgumentSpec s -> MacroSpec
- parseMacroSpecs :: Text -> Maybe MacroSpec
- noMacroArguments :: MacroSpec
Documentation
data ExpansionChunk Source #
Parsed chunk of an expandable command
LiteralChunk Text | regular text |
VariableChunk Text | inline variable |
IntegerChunk Integer | inline variable |
DefaultChunk ExpansionChunk Text | bracketed variable with default |
parseExpansion :: Text -> Maybe [ExpansionChunk] Source #
Parse a Text
searching for the expansions as specified in
ExpansionChunk
. $$
is used to escape a single $
.
resolveMacroExpansions Source #
:: (Text -> Maybe Text) | variable resolution |
-> (Integer -> Maybe Text) | argument index resolution |
-> [ExpansionChunk] | chunks |
-> Maybe Text | concatenated, expanded chunks |
Attempt to expand all of the elements in the given list using the two expansion functions. If the expansion of any chunk fails the whole expansion fails.
Macro | |
|
noMacroArguments :: MacroSpec Source #
Specification used when unspecified, no arguments.