err_syntax24.y revision 303975
1%{ 2int yylex(void); 3static void yyerror(const char *); 4%} 5 6%union { 7 int ival; 8 double dval; 9} 10 11%start expr 12%type <tag2> expr 13 14%token NUMBER 15 16%% 17 18expr : '(' recur ')' 19 ; 20 21recur : NUMBER 22 { $$ = 1; } 23 ; 24 25%% 26 27#include <stdio.h> 28 29int 30main(void) 31{ 32 printf("yyparse() = %d\n", yyparse()); 33 return 0; 34} 35 36int 37yylex(void) 38{ 39 return -1; 40} 41 42static void 43yyerror(const char* s) 44{ 45 printf("%s\n", s); 46} 47