Slide 6.6: Semantic functions (cont.)
Slide 7.1: A calculator language
Home

Denotational Semantics of Expressions (Cont.)


For better descriptions, the denotational definitions use two different notations: 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.