%% -*- mode: latex; TeX-master: "compilerbau.tex"; -*-

\begin{slide}{Unions in semantischen Werten}

\kopf{$ $Id: union.tex,v 1.1 2011-10-16 14:06:17 waldmann Exp $ $}

\begin{verbatim}
%union {
double     val;  /* Zahlen */
symrec  *tptr;   /* Symboltabellen-Eintrag */
}
%token <val>  NUM 
%token <tptr> VAR FNCT
%type  <val>  exp
%%
exp: NUM         { $$ = $1; }
 | VAR         { $$ = $1->value.var; }
 | VAR '=' exp { $$ = $3; $1->value.var = $3;}
 | FNCT '(' exp ')' 
        { $$ = (*($1->value.fnctptr))($3); }
 | exp '+' exp { $$ = $1 + $3; }
\end{verbatim}

\end{slide}
