bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

yacc compatibility bug


From: Vol Litwr
Subject: yacc compatibility bug
Date: Mon, 31 Oct 2011 08:11:13 +0300

//This code works with yacc but it doesn't work with bison -y. :-(
//The problem is TAB---the compiler doesn't see it at the code of
y.tab.c produced by bison

%token DIGIT
%left '+'
%%
list:
| list '\n'
| list expr '\n' {printf("%c%d\n", TAB, $2);}
;
expr: DIGIT
| expr '+' expr {$$ = $1 + $3;}
;
%%
#define TAB '\t'

int yylex () {
  int c;
  while ((c = getchar()) == ' ' || c == TAB);
  if (isdigit(c)) {
       yylval = c - '0';
       return DIGIT;
  }
  return c;
}

int yyerror() {}

main () {
  yyparse();
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]