Contents    Page-10    Prev    Next    Page+10    Index   

The Semantic Actions[slide by John Werth.]

Semantic actions refer to the elements of the production by a positional notation. $$ denotes the left side nonterminal. $n refers to the nth symbol on the right-hand side.

For example:


   expr : expr '+' term  { $$ = $1 + $3; }

The default action action is { $$ = $1; }. For this reason, we do not need to have an explicit action for


   expr : term