%{ /* initial stuff here */ typedef union { int i; double r; } yystype; #define YYSTYPE yystype static void yyerror(char *msg); %} %token FOO 17 "OOPH" %type script slash %% script : /* EMPTY */ {$$ = 0;} | script '?' slash FOO {$$ = $1 + $3;} | script 'a' 'b' {yyerror("'s okay"); $$ = 1000;} | script error slash {yyerrok;} | script FOO {YYERROR;} ; slash : '/' {$$ = 1;} ; %% /* trailing function declaration */ static void yyerror(char *msg) { parser::GetCurrentparser()->Error(parser_WARNING, msg); } void foo::ErrorGuts(int severity, char *severityname, char *msg) { printf("%s parse error: %s\n", severityname, msg); if (severity&parser_FREEMSG) free(msg); }