%{ /* In der Vorlesung am 7.1.2008 gemeinsam erstellte Loesung fuer die * konfliktfreie Erkennung von if-then-else via Assoziativität * mit lex und yacc. */ #include #define YYERROR_VERBOSE void yyerror(char *); %} %verbose %token IF EXPR ILLEGAL_CHAR %right THEN ELSE %% statement: IF EXPR THEN statement | IF EXPR THEN statement ELSE statement | other ; other: EXPR ; %% void yyerror(char *msg) { printf("\n%s\n", msg); } int main() { return yyparse(); }