File: recursive.gram

package info (click to toggle)
python-pegen 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,980 kB
  • sloc: python: 15,064; makefile: 89
file content (21 lines) | stat: -rw-r--r-- 696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
start: rules ENDMARKER
rules: rules rule | rule
rule: NAME ':' alternatives NEWLINE
alternatives: alternatives '|' alt_and_action | alt_and_action
alt_and_action: alt action | alt
alt: alt item | item
item: optional | atom '*' | atom '+' | atom '?' | atom
optional: '[' alternatives ']'
atom: group | NAME | STRING
group: '(' alternatives ')'

action: "{" ~ target_atoms "}" { target_atoms }
target_atoms:
    | target_atom target_atoms { target_atom + " " + target_atoms }
    | target_atom { target_atom }
target_atom:
    | "{" ~ target_atoms "}" { "{" + target_atoms + "}" }
    | NAME { name.string }
    | NUMBER { number.string }
    | STRING { string.string }
    | !"}" OP { op.string }