[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
glr-parser hands me the wrong token
From: |
Adam Wozniak |
Subject: |
glr-parser hands me the wrong token |
Date: |
Sat, 8 Apr 2023 11:22:03 -0700 |
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
====
# 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 $$ = 0;
808 printf("===> %s:%d source %d:%d '%s'\n", __FILE__, __LINE__, yylineno,
yylloc.first_column, yytext);
809 assert(yytext[0] != ',');
810 }
811 ;
language.l:
35 I_ZERO ([0])
36 I_NONZERO ([1-9][0-9]*)
37 INTEGER {I_ZERO}|{I_NONZERO}
[...]
92 {INTEGER} {⏎
93 flexdebug(__LINE__, yytext, (int) YYINTEGER,
yylineno, yylloc.first_column);⏎
94 return YYINTEGER;⏎
95 }⏎
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, '=', 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
===> language.ypp:808 source 1:0 ','
language: language.ypp:809: YYRESULTTAG yyuserAction(yyRuleNum, int,
yyGLRStackItem*, yyGLRStack*, long int, YYSTYPE*, YYLTYPE*): Assertion
`yytext[0] != ','' failed.
Aborted (core dumped)
- glr-parser hands me the wrong token,
Adam Wozniak <=