Debian Codegraph @

documentation/manual/grammar/series.yo

raw
1 A series of elements normally use left-recursion. For example, bf(C++)
2 supports em(string concatenation): series of double quote delimited tt(ASCII)
3 characters define a string, and multiple white-space delimited strings are
4 handled as one single string:
5 verb(
6 "hello" // multiple ws-delimited strings
7 " "
8 "world"
9
10 "hello world" // same thing
11 )
12 Usually a parser is responsible for concatenating the individual
13 string-parts, receiving one or more tt(STRING) tokens from the lexical
14 scanner. A tt(string) rule handles one or more incoming tt(STRING) tokens:
15 verb(
16 string:
17 STRING
18 |
19 string STRING
20 )
21 The above rule can be used as a prototype for recognizing a series of
22 elements. The token tt(STRING) may of course be embedded in another rule. The
23 generic form of this rule could be formulated as follows:
24 verb(
25 series:
26 unit
27 |
28 series unit
29 )
30 Note that the single element is em(first) recognized, whereafter the
31 left-recursive alternative may be recognized repeatedly.