%{ #include %} %union{ int whichDirn; char *str; } %token tok_DIRN %token tok_LOCN %token tok_DESCR %token tok_START %token tok_NAME %token tok_IDENT %token tok_STRING %% program : locnSpecList startSpec {printf("program : locnSpecList startSpec\n");} startSpec : tok_START tok_IDENT {printf("startSpec : tok_START tok_IDENT(%s)\n",$2);} locnSpec : tok_LOCN tok_IDENT nameSpec descrSpec exitList {printf("locnSpec : tok_LOCN tok_IDENT(%s) nameSpec descrSpec exitList\n",$2);} nameSpec : tok_NAME tok_STRING {printf("nameSpec : tok_NAME tok_STRING(%s)\n",$2);} descrSpec : tok_DESCR tok_STRING {printf("descrSpec : tok_DESCR tok_STRING(%s)\n",$2);} locnSpecList : locnSpec {printf("locnSpecList : locnSpec \n");} locnSpecList : locnSpecList locnSpec {printf("locnSpecList : locnSpecList locnSpec\n");} exitList : {printf("exitList :\n");} exitList : exitList exit {printf("exitList : exitList exit\n");} exit : tok_DIRN tok_IDENT {printf("exit : tok_DIRN(%d) tok_IDENT(%s)\n",$1,$2);} %% int yyerror(char *errMessage) { printf("Trouble: %s\n",errMessage); } main() { yyparse(); }