Debian Codegraph @

documentation/demos/manual/rpnline.yo

raw
1 Next consider the definition of the tt(line) nonterminal:
2 verb(
3 line:
4 '\n'
5 |
6 exp '\n'
7 {
8 cout << "\t" << $1 << endl;
9 }
10 ;
11 )
12 The first alternative is a newline character token; this means that
13 tt(rpn) accepts a blank line (and ignores it, since it has no associated
14 action). The second alternative is an em(expression) (tt(expr)), followed by a
15 newline. This alternative handles all expressions that are entered by the
16 user. The semantic value of the tt(exp) nonterminal is the value of tt($1)
17 because the tt(exp) nonterminal is the first symbol of the production
18 rule. The action simply prints the expression's value.
19
20 This action is unusual because it does not assign a value to tt($$). As a
21 consequence, the semantic value associated with tt(line) is not defined. This
22 becomes a bug if that value is ever used, but we don't use it: once tt(rpn)
23 has printed the value of the user's input line, that value is no longer
24 needed.
25