Type Checking 167
set of conditions on the values of the attributes in A(X
0
) ∪ A(X
1
) ∪ A(X
2
) ∪ · · · ∪ A(X
n
)
that further constrain an application of the production. The derivation of a sentence in the
attribute grammar is satisfied if and only if the context-free grammar is satisfied and all
conditions are true.
4.8.3 j-- Examples
We now look at how the semantics for some of the constructs in j-- can be expressed using
attribute grammars. Let us first consider examples involving just synthesized attributes.
Semantics of literals involves just the synthesis of their type. This can be done using a
synthesized attribute type:
literal ::= <int_literal>
type(literal) ← int
| <char_literal>
type(literal) ← char
| <string_literal>
type(literal) ← String
Semantics ...