%debug %{ # include # include static void yyerror (const char *msg); static int yylex (void); # define YYDEBUG 1 # define YYERROR_VERBOSE 1 %} %% input: a_b 'b' | a_c 'c' | error '!' { fprintf (stderr, "OK\n"); } ; a_b: 'a' { YYERROR; }; a_c: 'a' { YYERROR; }; %% static int yylex (void) { static const char *input = "a!"; return *input++; } static void yyerror (const char *msg) { fprintf (stderr, "%s\n", msg); } int main (void) { yydebug = 1; return yyparse (); }