When I try to use Bison to process tokens, I find that it works well when the input file is relatively small. However, when the file extends to more than 10 thousands lines, the flex works well(I can get the correct text from yytext, but not sure it is correctly send to Bison), the Bison failed with no rules in process(it succeeded when I made the input file small). I'm not sure if there are some features with Bison like limited buffer size or something like that?
//flex
"setb"|"SETB" {return SETB;}
[r][0-9]+ {yylval.reg = strdup(yytext); return R;}
//bison
a : R {$$ = e_aR_init($1);}
| V { $$ = e_aV_init($1);}
;
real_instr : SETB a COMMA e COMMA e {$$ = real_setb_init($2, $4, $6);}
yylval.reg has the right string, but when trying to print it from bison by add printf to R’s rule , it can’t even reach it, making it impossible to match the SETB rule of real_instr.
//================ I discover that yyparse() returns YYNOMEM which indicates the memory exhaustion, any solutions to fix it?