Flex rule with period "." not compiled

I ran into the problem of compiling this regex with flex

"on"[ \t\r]*[.\n]{0,300}"."[ \t\r]*[.\n]{0,300}"from"    {counter++;}

I had 100 hundred rules in the rules section of the flex specification file. I tried to compile it. flex -Ce -Ca rule.flexI waited 10 hours, but it did not end, so I killed him. I began to find the problem and narrowed the problem down to this rule. If I remove this rule from 100 rules, it will take 21 seconds to compile it into C code.

If I replace the period with some other character, it compiles successfully. eg.

"on"[ \t\r]*[.\n]{0,300}"A"[ \t\r]*[.\n]{0,300}"from"    {counter++;} 

compiles as soon as possible. Even the period followed / preceding a space compiles quickly

"on"[ \t\r]*[.\n]{0,300}" ."[ \t\r]*[.\n]{0,300}"from"    {counter++;}

I see from the flex manual that "." matches the letter "."

What is wrong with my rule?

+4
1

: [.\n], , , . , : . . (.|\n).

.

. ( ) , .

[.\n] , . , "." , "A" . , , . , , .

( ) .


, -v, . , , , 14 , . ( , , flex DFA, , , , 16 , flex 45 , , , 23 , , 6 , , . .)

$ cat badre.l
%%
"on"[ \t\r]*[.\n]{0,XXX}"."[ \t\r]*[.\n]{0,XXX}"from"
$ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
>   printf '{0,%d}:\t%24s\n' $i \
>      "$(flex -v -o /dev/null <( sed "s/XXX/$i/g" badre.l) |&
>         grep -o '.*DFA states')"
> done
{0,1}:        17/1000 DFA states
{0,2}:        25/1000 DFA states
{0,3}:        41/1000 DFA states
{0,4}:        73/1000 DFA states
{0,5}:       137/1000 DFA states
{0,6}:       265/1000 DFA states
{0,7}:       521/1000 DFA states
{0,8}:      1033/2000 DFA states
{0,9}:      2057/3000 DFA states
{0,10}:     4105/6000 DFA states
{0,11}:    8201/11000 DFA states
{0,12}:   16393/21000 DFA states
{0,13}:   32777/41000 DFA states
{0,14}:   65545/82000 DFA states

(.|\n) , ( ).

+3

All Articles