When there are multiple overlapping trailing contexts, re2c-generated code may set incorrect YYCTXMARKER value. The following example fails on input string that matches pattern "abb" [^c]: rule 1 matches and should consume single character a, but it consumes ab because YYCTXMARKER gets overwritten when trying to match rule 0.
Source code (1.re):
/*!re2c
"abb" / "c" { 0 }
"a" / "b" { 1 }
*/
Generated code:
/* Generated by re2c 0.13.6 on Thu Oct 1 21:57:46 2015 */
{
YYCTYPE yych;
if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch (yych) {
case 'a': goto yy3;
default: goto yy2;
}
yy2:
YYCURSOR = YYMARKER;
goto yy5;
yy3:
YYCTXMARKER = YYCURSOR + 1;
yych = *++YYCURSOR;
switch (yych) {
case 'b': goto yy4;
default: goto yy2;
}
yy4:
yych = *(YYMARKER = ++YYCURSOR);
switch (yych) {
case 'b': goto yy6;
default: goto yy5;
}
yy5:
YYCURSOR = YYCTXMARKER;
{ 1 }
yy6:
YYCTXMARKER = YYCURSOR + 1;
yych = *++YYCURSOR;
switch (yych) {
case 'c': goto yy7;
default: goto yy2;
}
yy7:
++YYCURSOR;
YYCURSOR = YYCTXMARKER;
{ 0 }
}
When there are multiple overlapping trailing contexts, re2c-generated code may set incorrect
YYCTXMARKERvalue. The following example fails on input string that matches pattern"abb" [^c]: rule1matches and should consume single charactera, but it consumesabbecauseYYCTXMARKERgets overwritten when trying to match rule0.Source code (1.re):
Generated code: