Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!ucsd!nosc!humu!uhccux!lee From: lee@uhccux.UUCP (Greg Lee) Newsgroups: comp.sources.bugs Subject: flex bug with |'d patterns and $. Keywords: flex Message-ID: <1847@uhccux.UUCP> Date: 15 May 88 11:22:32 GMT Organization: U. of Hawaii, Manoa (Honolulu) Lines: 74 When patterns associated with several start states are or'd with "|", a "$" in a pattern may cause an incorrect match by a flex-generated program. Here is some sample data: ----------------input data------------- none It's as easy as one, two, three. first It's as easy as one, two, three. second It's as easy as one, two, three. --------------end data----------------- And here is a program that works correctly when flex'd: ------------program that works--------- %s FIRST SECOND %% "two" | "one" | "three." printf(""); "first" printf("State 1"); BEGIN FIRST; "second" printf("State 2"); BEGIN SECOND; %% main() { yylex(); } ----------end of program that works----- From the above input and the above program, comes this output: -------output of program that works----- none It's as easy as one, two, State 1 It's as easy as , two, State 2 It's as easy as one, , ----end of output of program that works----- But change the program by adding "$" to the pattern for start state 0: ---------program that doesn't work--------- %s FIRST SECOND %% "two" | "one" | "three."$ printf(""); "first" printf("State 1"); BEGIN FIRST; "second" printf("State 2"); BEGIN SECOND; %% main() { yylex(); } ----end of program that doesn't work------- You'd think the output would be the same, but instead you get: -----output of program that doesn't work--- none It's as easy as one, two, State 1 It's as easy as wo, State 2 It's as easy as one, hree. --end of output of program that doesn't work--- (Lex doesn't understand this sort of construction at all.) Greg, lee@uhccux.uhcc.hawaii.edu