colap 0.2.0

A lightweight, human-friendly configuration language parser & code generator
Cola: MarkdownItem*;

MarkdownItem: HeadingLine | CodeBlock | ParagraphLine;

CodeBlock: ColaCodeBlock | RegularCodeBlock;

ColaCodeBlock: ColaCodeStart ColaSyntax ColaCodeEnd;

ColaSyntax: Entity*;

Entity: PluralEntity | SingularEntity;

PluralEntity: Identifier PluralKeyword Identifier Colon EntityDefinition Semicolon;
SingularEntity: Identifier Colon EntityDefinition Semicolon;

EntityDefinition: NestedBlock*;

NestedBlock: FieldList | Entity;

FieldList: Field | FieldList Comma Field;

Field: Identifier Colon FieldValue;

FieldValue: QuotedStringDouble | QuotedStringSingle | Number | BooleanTrue | BooleanFalse;

RegularCodeBlock: RegularCodeStart RegularCodeLine* RegularCodeEnd;

RegularCodeStart: RegularCodeStartNamed | RegularCodeStartUnnamed;

// Special rule always applied to each token.
Layout: WS+ | EMPTY;

terminals
	BooleanTrue: 'true';
	BooleanFalse: 'false';
	ColaCodeStart: /```[ \t]*cola[ \t]*\n/;
    ColaCodeEnd: /```[ \t]*\n?/;
	Colon: ':';
	Comma: ',';
	HeadingLine: /#{1,6}[ \t]+[^\n]*\n/;
	Identifier: /[a-zA-Z_][a-zA-Z0-9_.-]*/;
    Number: /[+-]?[0-9]+(\.[0-9]+)?/;
	ParagraphLine: /[^#`\n][^\n]*\n/;
	PluralKeyword: "plural";
	QuotedStringDouble: /"([^"\\]|\\.)*"/;
    QuotedStringSingle: /'([^'\\]|\\.)*'/;
	RegularCodeLine: /[^\n]*\n/;
	RegularCodeStartNamed: /```[a-z]+[ \t]*\n/;
    RegularCodeStartUnnamed: /```[ \t]*\n/;
	RegularCodeEnd: /```[ \t]*\n?/;
	Semicolon: ';';
	UnquotedString: /[a-zA-Z0-9_.-]+/;
	// Terminal for whitespace used by the Layout rule
    WS: /\s+/;