Commit grammar
Ambiguity
Grammars rejected before any header is read.
A grammar is validated on load. An invalid grammar exits 1 with one
error and lints nothing.
An optional slot does not separate its neighbours: the slots on either side are checked against each other too.
Malformed slots
| Error | Cause |
|---|---|
slot `x` needs exactly one of `kind`, `delimiters` or `one-of` | None of them, or more than one |
slot `separator` is a `symbol`, so it cannot match `::` | A spelling the kind cannot match |
`gap` does not apply to slot `emoji` | A misplaced key on a one-of |
Indistinguishable slots
| Error | Cause | Resolution |
|---|---|---|
`a` takes the whole run, leaving nothing for `b` | A word, or unrestricted symbols, followed by the same kind | A symbol or delimited slot between them |
`a` and `b` both start with `x` | Neighbouring spellings share a prefix | Distinct first characters |
`b` takes anything, `a`'s spellings included | A closed set before an unrestricted slot of the same alphabet | Close the second slot's values |
`a` and `b` carry the same delimiters | Two delimited slots with the same pair, at any distance | A different pair; a shared opener alone is allowed |
`a` and `b` can start on the same input | Overlapping one-of options | Close or separate the options |
`a` is optional after a gap, so it can take the start of the description | An optional word or unrestricted symbols slot after a gap | required = true, or a delimited slot |
word is one alphabet; symbols and symbol share the other.
Examples
[[commit.slots]]
name = "type"
kind = "word"
[[commit.slots]]
name = "subtype"
kind = "word"[[commit.slots]]
name = "modifiers"
kind = "symbols"
values = ["!", ":"]
[[commit.slots]]
name = "separator"
kind = "symbol"
values = [":"][[commit.slots]]
name = "modifiers"
kind = "symbols"
values = ["!"]
[[commit.slots]]
name = "separator"
kind = "symbol"[[commit.slots]]
name = "scope"
delimiters = ["(", ")"]
[[commit.slots]]
name = "ticket"
delimiters = ["(", ")"][[commit.slots]]
name = "emoji"
kind = "symbols"
values = ["✨"]
required = true
gap = true
[[commit.slots]]
name = "keywords"
kind = "word"