%{ #include extern int yylex(void); extern void yyerror(const char*); %} %token SEMICOLON TIMES CARPET CLEANED ON DONE DATE INTEGER NONINTEGER %define parse.error verbose %start input %% input : commands donecommand ; donecommand : DONE SEMICOLON ; commands : command commands | %empty ; command : CARPET INTEGER area SEMICOLON | CLEANED CARPET INTEGER ON DATE SEMICOLON ; area : number | number TIMES number ; number : INTEGER | NONINTEGER; %% int main(void) { printf("Write a complete input, ending with \"done\", a semicolon and EOF:\n"); yyparse(); printf("Ok!\n"); return 0; } void yyerror(const char *s) { printf("Incorrect calendar input! Error message: %s\n", s); } int yywrap(void) { return 1; }