#133 Unexpected expansion of definition in trailing context

2.5.35
open
nobody
None
5
2012-01-06
2012-01-06
O. Andersen
No

The following simple flex file gives different results with 2.5.35 compared to 2.5.4:

%option noyywrap

ab a|b

%%

a{ab} printf("T");
x/a{ab} printf("X");

%%

int main(void)
{
yylex();
}

Test output with flex 2.5.4:

$ ~/flex-2.5.4/flex test.flex
$ gcc lex.yy.c
$ echo a b aa ab bb xa xb xaa xab xbb | ./a.out
a b T T bb xa xb XT XT xbb

Test output with flex 2.5.35:

$ flex test.flex
$ gcc lex.yy.c
$ echo a b aa ab bb xa xb xaa xab xbb | ./a.out
a b T T bb xa Xb XT xT Xbb

As expected, a{ab} = a(a|b) = aa|ab in both 2.5.4 and 2.5.35.

2.5.4 does the same in trailing context. 2.5.35, however, seems not to add brackets in trailing context, which gives x/a{ab} = x/aa|b.

This seems counter-intuitive to me. Is this change really necessary, or would it be possible to restore the behaviour found in flex 2.5.4?

Øistein E. Andersen

Discussion