Copyright | (c) Fernando Freire 2018 |
---|---|
License | BSD3 |
Maintainer | dogonthehorizon@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module provides parser-combinators for Git configuration files.
It attempts to follow the syntax for Git configuration files outlined in this document:
https://git-scm.com/docs/git-config/2.16.0#_syntax
One notable omission is that no legacy compatability is explicitly provided (e.g. dot-separated subsection names are not guaranteed to parse correctly).
Synopsis
- type Parser = Parsec Void Text
- data Section = Section [Text] (HashMap Text Text)
- type GitConfig = [Section]
- spaceConsumer :: Parser ()
- lexeme :: Parser a -> Parser a
- symbol :: Text -> Parser Text
- brackets :: Parser a -> Parser a
- quotes :: Parser a -> Parser a
- escSeq :: Parser Char
- sectionName :: Parser [Text]
- sectionHeader :: Parser [Text]
- variableName :: Parser Text
- variableValue :: Parser Text
- mapping :: Parser (Text, Text)
- section :: Parser Section
- config :: Parser GitConfig
- parseConfig :: Text -> Either GitConfigError GitConfig
Types
Lexer
spaceConsumer :: Parser () Source #
Whitespace consumer for this parser.
Whitespace is considered to be any space character
(including carriage return) as well as line comments starting with #
and
`;` .
Parser
sectionName :: Parser [Text] Source #
Parse a section name.
Section names are case-insensitive. Only alphanumeric characters, - and . are allowed in section names. Sections can be further divided into subsections. To begin a subsection put its name in double quotes, separated by space from the section name, in the section header.
sectionHeader :: Parser [Text] Source #
Parse a section header.
A section begins with the name of the section in square brackets and continues until the next section begins.
variableName :: Parser Text Source #
Parse a variable name.
The variable names are case-insensitive, allow only alphanumeric characters and -, and must start with an alphabetic character.
variableValue :: Parser Text Source #
Parse a variable value.
mapping :: Parser (Text, Text) Source #
Parse a tuple of Text
key and value.
in the form name = value (or just name, which is a short-hand to say that the variable is the boolean "true"). -- FIXME parse boolean true
A line that defines a value can be continued to the next line by ending it with a ; the backquote and the end-of-line are stripped. Leading whitespaces after name =, the remainder of the line after the first comment character # or ;, and trailing whitespaces of the line are discarded unless they are enclosed in double quotes. Internal whitespaces within the value are retained verbatim.