| 1 | -- AST for pgen grammar.
|
| 2 | -- Contrast with asdl.asdl
|
| 3 |
|
| 4 | module pgen
|
| 5 | {
|
| 6 | term =
|
| 7 | String(string s) -- '(', etc.
|
| 8 | | Name(string n) -- expr_stmt
|
| 9 | | Group(term t) -- (expr stmt)
|
| 10 | | Repeat(term t, int times) -- foo+, foo* (';' small_stmt)*
|
| 11 | | Optional(term t) -- ['=' test]
|
| 12 | | Seq(term* terms) -- A B
|
| 13 | | Alt(term* alts) -- '+=' X | '-=' X Y
|
| 14 | -- | has low precedence
|
| 15 |
|
| 16 | -- Not used because we just use a simple dict of string -> term
|
| 17 | -- Terms are concatenated
|
| 18 | -- rule = (string lhs, term rhs)
|
| 19 |
|
| 20 | -- grammar = (rule* rules)
|
| 21 | }
|