EBNF Construct | Description |
---|---|
( rhs ) | Right hand side elements can be grouped. |
rhs * | Denotes zero or more repetitions of rhs. |
rhs + | Denotes one or more repetitions of rhs. |
rhs ? | Denotes that rhs is optional. |
Use of these constructs cause internal productions to be added
to the grammar. These can be viewed by setting the debug flag to
1
when parsing the spec file.
For example, the spec file:
lines -> line* ; line -> A? | B+ | C D* ;
results in the following grammar:
lines.clos1 -> lines.clos1 -> lines.clos1 line lines -> lines.clos1 line.opt2 -> line.opt2 -> A line -> line.opt2 line.posclos3 -> B line.posclos3 -> line.posclos3 B line -> line.posclos3 line.clos4 -> line.clos4 -> line.clos4 D line -> C line.clos4
The internal productions contain action code that implement the
obvious actions. Productions generated with "+"
or "*"
return a list of elements. Productions generated with "?"
return the optional value or the value None
. Groupings of
elements return a list of the elements.
See the PyGgy Home Page.