%{ #include #include #include #include "lists.h" extern int yylineno; extern FILE* yyin; extern void yyerror(char const *); %} /* Les symboles terminaux */ %token PLUS %token LPAR RPAR %token IF THEN ELSE %token LET EQ IN %token ID %token CONST %union { char* str; } /* L'axiome, ou symbole de depart */ %start S %% /* Section grammaire */ S: b_expression {printf("Programme syntaxiquement correcte\n");} b_expression: e_expression: %% /* Le code additionnel */ void yyerror(char const *str) { fprintf(stderr,"Ligne %d : %s\n", yylineno, str); exit(EXIT_FAILURE); } int main(int argc, char* argv[]) { if ( argc > 1 ) { if((yyin = fopen( argv[1], "r" ))==NULL) exit(EXIT_FAILURE); yyparse(); fclose(yyin); } else exit(EXIT_FAILURE); exit(EXIT_SUCCESS); }