%{ #include extern void yyerror(char*); %} %token MEETING LECTURE LAB DONE DATE TIME PLACE %define parse.error verbose %start input %% input : commands DONE ; commands : command commands | %empty ; command : MEETING time_and_place | LECTURE time_and_place | LAB time_and_place ; time_and_place: DATE TIME TIME PLACE ; %% int main() { printf("Write a complete input, ending with \"done\" and CTRL-D:\n"); yyparse(); printf("Ok!\n"); return 0; } void yyerror(char *s) { printf("Incorrect calendar input! Error message: %s\n", s); } int yywrap(void) { return 1; }