/* match3.y MR 04/07/99 - 05/07/99 Input file to 'bison' (or 'yacc'). How to generate the parser program: 1) Run bison on this file: bison match3.y 2) Compile the bison output: gcc match3.tab.c -o match3 */ %token ID %token OTHER /* Disambiguating rules: These are such that an ID is glued to a following ;, ( or { if possible; that is, the ID ;, ID (, or ID { combination is shifted, instead of reducing the ID alone. */ %right ID %left ';' %left '(' %left '{' %start list %% list : /*empty*/ | list item ; /* Functie __deklaraties__ zitten hier nog niet in: */ item : ID rbr block { printf( "FDEF\n" ); } | ID rbr { printf( "FCALL\n" ); } | ID { printf( "id\n" ); } | block { printf( "block, not func body\n" ); } | ';' { printf( ";\n" ); } | rbr { printf( "rbr, no func call\n" ); } | OTHER { printf( "other\n" ); } ; /* Er zijn 5 basic building blocks: ID Identifier (starting with letter) ; OTHER Any other token than ID, ;, (, ), {, } ( ...anything... ) ``rbr'' (round brackets) { ...anything... } ``block'' */ block : '{' list '}' ; /* ``Round BRackets'' */ rbr : '(' list ')' ; %% #include main() { yyparse(); } yyerror( char * str ) { printf( "match3: %s\n", str ); } int isLetter( int c ) { if ( 'a'