Debian Codegraph @

documentation/manual/grammar/semantics.yo

raw
1 A language's grammar rules define its syntax. Its semantics are defined
2 through semantic values that can be associated with terminal and nonterminal
3 symbols, and generally by the actions taken when nonterminals or parts of
4 production rules have been recognized.
5
6 For example, the calculator performs real-life calculations because the value
7 associated with each expression is its computed numeric value; it correcly
8 performs addition because the action for an expression like `x + y' is to add
9 those numbers and to return their sum.
10
11 Two ways of defining semantics have already been discussed:
12 itemization(
13 it() link(using a single data type for all semantic
14 values)(STYPE);
15 it() Semantic values representing link(several alternative data
16 types)(UNION).
17 )
18
19 A third way for defining semantic values is discussed next (cf. section
20 ref(POLYMORPHIC)). em(Shorthand notations) that can be used in action blocks
21 are described next (cf. section tt(ACTIONS)). Finally, Action blocks usually
22 appear at the end of production rules. But in fact they can be defined
23 anywhere in production rules. Refer to this section's final subsection
24 (section ref(MIDACTIONS)) for the characteristics of such em(mid-rule action
25 blocks).