bug-bison
[Top][All Lists]
Advanced

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

Re: yacc compatibility bug


From: Hans Aberg
Subject: Re: yacc compatibility bug
Date: Mon, 31 Oct 2011 10:58:30 +0100

On 31 Oct 2011, at 06:11, Vol Litwr wrote:

> //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();
> }

This might be something for Paul Eggert to reply on: Bison only supports Yacc 
as to what is in the POSIX standard I think.

The problem is here that the epilogue of the grammar file is copied by Bison 
verbatim to the end of the parser implementation file. So apparently, the Yacc 
you are using is doing it differently.

Hans





reply via email to

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