Debian Codegraph @

documentation/manual/grammar/optseries.yo

raw
1 An em(optional) series of elements also use left-recursion, but the single
2 element alternative remains empty. For example, in bf(C++) a compound
3 statement may contain statements or declarations, but it may also be empty:
4 verb(
5 opt_statements:
6 // empty
7 |
8 opt_statements statements
9 )
10 The above rule can be used as a prototype for recognizing a series of
11 elements: the generic form of this rule could be formulated as follows:
12 verb(
13 opt_series:
14 // empty
15 |
16 opt_series unit
17 )
18 Note that the empty element is recognized em(first), even though it is
19 empty, whereafter the left-recursive alternative may be recognized repeatedly.
20 In practice this means that an em(action block) may be defined at the empty
21 alternative, which is then executed prior to the left-recursive
22 alternative. Such an action block could be used to perform initializations
23 necessary for the proper handling of the left-recursive alternative.
24