help-bison
[Top][All Lists]
Advanced

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

Re: Is there a replacement for yychar


From: Akim Demaille
Subject: Re: Is there a replacement for yychar
Date: Mon, 12 Jan 2015 11:22:22 +0100

> Le 11 déc. 2014 à 19:17, Matthias Simon <address@hidden> a écrit :
> 
> Hi,
> 
> I have a problem compiling my parser generated by Bison 3.0.2. For error 
> recovery I use the lookahead variable `yychar' like this:
> 
> ...
>    | error { if (yychar != '}' && yychar != ';') yyclearin; else yyerrok; }
>    ;
> 
> But in commit 39be90223b73a42d249f99cdf283c4ab46a10a21 this variable was 
> removed from $parser_class_name::parse(), which means my grammar does not 
> compile for recent bison releases anymore. Is there a replacement for 
> `yychar', which also works for older bison versions, like 2.7? The manual 
> still mentions `yychar', and suggests nothing there and I am little clueless. 
> I could workaround that within my build system, but I would prefer keeping 
> things simple.

Hi Matthias,

I'm very afraid with changes in yychar, yytoken, and yylval.
And in particular, I believed that no one in C++ was depending
on them.  They are officially supported for C, as compatibility
with Yacc.

Maybe I could introduce references for you.  Except that yychar
no longer exists at all, it is only the equivalent of yytoken
that still exists as "yyla.type_get()".

However, can't you just avoid depending on yychar this way?
Can't you pull out the yychar at the level of the rule itself?

This, for instance, seems to leave bison happy (no conflicts):

%left '+'

%%
line:
  '{' exp '}'
| exp ';'
| exp 'a'
| '{' error '}'
| error ';'
| error
;

exp:
  exp '+' exp
| '0'




reply via email to

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