glr-parser hands me the wrong token
Adam Wozniak <[email protected]> Sat, 8 Apr 2023 11:22:03 -0700
| Newsgroups | gmane.comp.parsers.bison.bugs |
|---|---|
| Message-ID | <CA+JkkaA=epdQK+gWPFXoW58Tgi8A07qnun4DMXtQ7eXM_kEGfg@mail.gmail.com> |
this is all from the README.txt along with sample code that demonstrates
the problem i put up on
https://github.com/GorillaSapiens/bison_glr_bug
=3D=3D=3D=3D
# bison_glr_bug
######## the bug
essentially, i believe the Bison glr-parser is handing me the wrong
yylloc and yytext under some circumstances.
in my code...
language.ypp:
805 iconst : YYINTEGER
806 {
807 $$ =3D 0;
808 printf("=3D=3D=3D> %s:%d source %d:%d '%s'\n", __FILE__, __LINE__, yyli=
neno,
yylloc.first_column, yytext);
809 assert(yytext[0] !=3D ',');
810 }
811 ;
language.l:
35 I_ZERO ([0])
36 I_NONZERO ([1-9][0-9]*)
37 INTEGER {I_ZERO}|{I_NONZERO}
[...]
92 {INTEGER} {=E2=8F=8E
93 flexdebug(__LINE__, yytext, (int) YYINTEGER,
yylineno, yylloc.first_column);=E2=8F=8E
94 return YYINTEGER;=E2=8F=8E
95 }=E2=8F=8E
As you can see, the yytext for an YYINTEGER should **NEVER** contain a ','.
But yet, i'm seeing this happen (see below).
######## how to reproduce
$ git clone https://github.com/GorillaSapiens/bison_glr_bug.git
[...]
$ make
[...]
$ ./language program.txt
.l line 88, 'b', 258, source 1:1
.l line 108, '=3D', 61, source 1:3
.l line 88, 'a', 258, source 1:5
.l line 108, '<', 60, source 1:6
.l line 93, '1', 299, source 1:7
.l line 108, ',', 44, source 1:8
=3D=3D=3D> language.ypp:808 source 1:0 ','
language: language.ypp:809: YYRESULTTAG yyuserAction(yyRuleNum, int,
yyGLRStackItem*, yyGLRStack*, long int, YYSTYPE*, YYLTYPE*): Assertion
`yytext[0] !=3D ','' failed.
Aborted (core dumped)