Brian Picciano
4870455430
The new gg format is based on a BNF file which can be found in the `gg` directory. The code for decoding `.gg` files has been refactored to mirror that file. The result is more resilient parsing, better errors, and a greater ability to extend the format in the future. The new decoder is notable in that it does not use a lexer. Both lexing and parsing are done in a single step. The format syntax itself has also been modified. Rather than using semi-colons everywhere, commas are used as separators in tuples. Additionally the final comma/semi-colon is no longer required.
24 lines
1.1 KiB
BNF
24 lines
1.1 KiB
BNF
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
|
<positive-number> ::= <digit>+
|
|
<negative-number> ::= "-" <positive-number>
|
|
<number> ::= <negative-number> | <positive-number>
|
|
|
|
<name> ::= (<letter> | <mark>) (<letter> | <mark> | <digit>)*
|
|
|
|
<tuple> ::= "(" <tuple-tail>
|
|
<tuple-tail> ::= ")" | <tuple-open-edge>
|
|
<tuple-open-edge> ::= <value> <tuple-open-edge-value-tail>
|
|
| <tuple> <tuple-open-edge-tail>
|
|
<tuple-open-edge-tail> ::= ")" | "," <tuple-tail>
|
|
<tuple-open-edge-value-tail> ::= <tuple-open-edge-tail> | "<" <tuple-open-edge>
|
|
|
|
<graph> ::= "{" <graph-tail>
|
|
<graph-tail> ::= "}" | <name> "=" <graph-open-edge>
|
|
<graph-open-edge> ::= <value> <graph-open-edge-value-tail>
|
|
| <tuple> <graph-open-edge-tail>
|
|
<graph-open-edge-tail> ::= "}" | ";" <graph-tail>
|
|
<graph-open-edge-value-tail> ::= <graph-open-edge-tail> | "<" <graph-open-edge>
|
|
|
|
<value> ::= <name> | <number> | <graph>
|
|
<gg> ::= <eof> | <value> <gg>
|