/* match2.y MR 04/07/99 Input file to 'bison' (or 'yacc'). How to generate the parser program: 1) Run bison on this file: bison match2.y 2) Compile the bison output: gcc match2.tab.c -o match2 */ %token ID %token OTHER %start list %% list : /*empty*/ | list item ; item : nobr { printf( "SITEM\n" ); } | '(' list ')' { printf( "()ITEM\n" ); } | '{' list '}' { printf( "{}ITEM\n" ); } ; nobr : ID { printf( "ID\n" ); } | ';' { printf( ";\n" ); } | OTHER { printf( "OTHER\n" ); } ; %% #include main() { yyparse(); } yyerror( char * str ) { printf( "match2: %s\n", str ); } int isLetter( int c ) { if ( 'a'