Semantic Functions


A semantic function is specified for each syntactic domain. Each semantic function is given a different name based on its associated syntactic domain. A common convention is to use the boldface letter corresponding to the elements in the syntactic domain. Thus the value function from the syntactic domain Digit to the integers is written as follows: The value of a semantic function is specified recursively on the trees of the syntactic domains using the structure of the grammar rules. This is done by giving a semantic equation corresponding to each grammar rule. For example, the grammar rules for digits
   D ::= '0' | '1' | ... | '9'
give rise to the syntax tree nodes


and the semantic function D is defined by the following semantic equations,


representing the value of each node. This cumbersome notation is shortened to the following:
   D[['0']]= 0, D[['1']]= 1, ..., D[['9']]= 9
The double brackets [[...]] indicate that the argument is a syntactic entity consisting of a syntax tree node with the listed arguments as children.