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 }
|