The .Gram language, a guide
A guide to writing grammars, one topic a page, in the order a grammar needs them: what every grammar uses
first, what is used often next, and the advanced material last; each feature with what it means, a small grammar that uses it,
the cases worth knowing, and the form the generator refuses with the diagnostic it gives. The specification is
syntax.md; every message is in diagnostics.md; the tool that
generates outside a build is cli.md.
| Page | What it covers | |
|---|---|---|
| 01 | The grammar and its host | [Gram], rules and declarations, @ and C#, imports; a first look at trivia, Std, the built-in rules and the supplied names |
| 02 | Elements | literals and escapes, case-insensitive literals, element sets, any, none, eol, eof, eos |
| 03 | Composition | &, \|, groups, atomic groups, quantifiers, lookahead, the order of operators |
| 04 | Rules | declarations, parameters, levels, left recursion, binding powers |
| 05 | Trivia and words | trivia, ~, wordboundary, word |
| 06 | Reading over tokens | Lexical = true: how a grammar is cut, what changes, rules that give back, terminals, what cannot be cut |
| 07 | Captures and values | captures, what a rule gives back, =>, the supplied names, on fail |
| 08 | Publication | parse, find, as, access, positional, stream, yield |
| 09 | The standard library | every rule of Std |
| 10 | Namespaces | namespaces, imports, rebinding with with |
| 11 | Guards and switch |
when @(…), conditions when A is B, switch |
| 12 | Text bindings | $q: X, $q, X{#q} |
| 13 | Recovery | recover, the names a recovery is handed, OnRecovered |
| 14 | The seam with C# | predicates, external recognizers, C# in constructions and guards |
| 15 | Context and state | context, state, with state, indentation before a layout layer |
| 16 | Host options | Carrier, buffered input, [GramParserVariant], [GramInclude] |
| 17 | Quick reference | every sign and word on one page |
Every example runs
Every grammar on these pages is compiled by the tests and every example under it is run, so a page that disagrees with the generator is a failing test rather than a stale page.