git-config-0.1.2: A simple parser for Git configuration files

Copyright(c) Fernando Freire 2018
LicenseBSD3
Maintainerdogonthehorizon@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Text.GitConfig.Parser

Contents

Description

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

Types

data Section Source #

Constructors

Section [Text] (HashMap Text Text) 
Instances
Eq Section Source # 
Instance details

Defined in Text.GitConfig.Parser

Methods

(==) :: Section -> Section -> Bool #

(/=) :: Section -> Section -> Bool #

Show Section Source # 
Instance details

Defined in Text.GitConfig.Parser

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 `;` .

lexeme :: Parser a -> Parser a Source #

A lexeme for this parser.

symbol :: Text -> Parser Text Source #

A symbol for this parser.

brackets :: Parser a -> Parser a Source #

Return a parser in between brackets.

quotes :: Parser a -> Parser a Source #

Return a parser in between quotes.

escSeq :: Parser Char Source #

Parser for escape sequences.

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.

section :: Parser Section Source #

Parse a complete git config section.

config :: Parser GitConfig Source #

Parse a complete git config.

parseConfig :: Text -> Either GitConfigError GitConfig Source #