For better descriptions, the denotational definitions use two different notations:
- In productions and parse trees, the symbols
<
and >
enclosing a nonterminal are removed.
For example,
<N> ::= <N> <D> | <D>
is replaced by
N ::= N D | D
- The denotational descriptions have retained the use of quotes to distinguish syntactic from semantic entities.
In denotational semantics this is not as necessary as in other semantic descriptions, since arguments to semantic functions are always syntactic entities.
Thus, we could drop the quotes and write
D[[0]] = 0
, and so on.
For clarity, we will generally continue to use the quotes, however.
To see how these equations can be used to obtain the semantic value of an expression we compute E[[(2+3)*4]]
or, more precisely,
E[[ '(' '2' '+' '3' ')' '*' '4' ]]
The semantic value is calculated as follows:
E[[ '(' '2' '+' '3' ')' '*' '4' ]]
= E[[ '(' '2' '+' '3' ')' ]] * E[[ '4' ]]
= E[[ '2' '+' '3' ]] * N[[ '4' ]]
= ( E[[ '2' ]] + E[[ '3' ]] ) * D[[ '4' ]]
= ( N[[ '2' ]] + N[[ '3' ]] ) * 4
= ( D[[ '2' ]] + D[[ '3' ]] ) * 4
= ( 2 + 3 ) * 4 = 5 * 4 = 20
Therefore, the expression "(2+3)*4
" is a syntactic phrase that denotes the abstract object, namely the integer 20.