Re: YYRECOVERING() in yylex function

r0ller <[email protected]> Fri, 14 Mar 2025 09:15:43 +0000 (GMT)
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi All,It turned out in the end that it is my fault as I don't generate any=
 header files by bison which may then contain the necessary macro definitio=
n. Nevertheless, I also realized that it's better to return YYUNDEF from yy=
lex than triggering YYERROR from an action. This made using YYRECOVERING in=
 yylex superfluous. So issue solved :)Best regards,r0ller-------- Eredeti l=
ev=C3=A9l --------Felad=C3=B3: r0ller <[email protected]>D=C3=A1tum: 2025 =
m=C3=A1rcius 12 21:54:11T=C3=A1rgy: Re: YYRECOVERING() in yylex functionC=
=C3=ADmzett: Nathanael Bracy <[email protected]>Hi Nathanael,Unfortunatel=
y the project is quite big but I want to make a minimal reproducible exampl=
e for it. Before doing so though, I'd like to understand if it makes sense =
at all to use YYRECOVERING() in yylex. I have a rule for each token a valid=
ating action which triggers YYERROR if the token is invalid. The issue I no=
ticed is that e.g. for the input A B C where token B is invalid, YYERROR is=
 triggered after which yylex is called by bison. Thus yylex processes the i=
nput and returns the next token (C). Then the action set up for error recov=
ery takes place which checks if it's already the end of input. The end of i=
nput check returns true since token C has been returned by yylex in which c=
ase I raise YYABORT. That's why I thought, if I could check in yylex that Y=
YRECOVERING() is 1 then it could return the previous token not the next. Ho=
wever, as I reported, I get a compile time error since YYRECOVERING() may h=
ave been designed to be used only in actions. I hope I could sum up clearly=
 what I'm doing. Nevertheless, I'll try to make a minimal example.Best rega=
rds,r0ller-------- Eredeti lev=C3=A9l --------Felad=C3=B3: Nathanael Bracy =
<[email protected]>D=C3=A1tum: 2025 m=C3=A1rcius 12 16:41:07T=C3=A1rgy: R=
e: YYRECOVERING() in yylex functionC=C3=ADmzett: r0ller <[email protected]=
>Hi r0llerxCould I see your code somewhere? Perhaps you're forgetting to in=
clude a header or your linker isn't linking against the right objects.On We=
d, Mar 12, 2025 at 5:27=E2=80=AFAM r0ller <[email protected]> wrote:Hi All=
,I tried to use the YYRECOVERING() macro in my implementation of yylex but =
I get the following error: "error: use of undeclared identifier 'yyerrstatu=
s_'"I don't know if it's the intended behaviour just wanted to ask (as I th=
ink I can work it around to detect recovering status).Best regards,r0ller