%class sp_yacc %token ATOM VAR include <yacc.h> //#define YYDEBUG 1 define sp_con(X) define sp_var(X) define sp_fun0(P) define sp_fun1(P,A1) define sp_fun2(P,A1,A2) cout << "fun/2: " << P << " " << A1 << " " << A2 << endl; %start goal goal: term { cerr << "goal: " << $1.v << endl; return $1.v; } atom: ATOM var: VAR fun: atom '(' ')' | atom '(' term ')' { cout << "fun/1: " << $1 << " " << $3 << endl; } | atom '(' term ',' term ')' { sp_fun2(&$1,&$3,&$5) } | atom '(' term ',' term ',' term ')' term: atom { cout << "atom: " << $1 << endl; } | var { cout << "var: " << $1 << endl; } | fun ; compound: atom '(' arguments ')' arguments: term | arguments ',' term
Hush Online Technology
hush@cs.vu.nl
09/09/98 |
![]() |
![]() |