Nimony

The road to Nim 3

nimgrammar

nimony/src/nifler2/nimgrammar.nim

The grammar of Nim.

Transcribed from Nim's doc/grammar.txt, which is itself generated from the #| comments in compiler/parser.nim. See doc/internals/parser_generator.md for the notation.

Transcription rules followed here:

  • doc/grammar.txt is the source, and where it disagrees with what

parser.nim actually does, the transcription follows parser.nim and says so in a # GRAMMAR.TXT: note. Collecting those is one of the points of the exercise.

  • Ordered choice (/) does not exist in the notation. Every / in the

original is resolved into either disjoint alternatives (usually by an indentation class), a left-factored set of entries, or a declared predicate — and the ones that needed a predicate are marked # PRED.

  • OP0..OP10 and the eleven precedence-level rules are gone; binary(...)

owns precedence, exactly as parser.nim does.

  • DED is implicit in indented(...).