Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ames!sdcsvax!ucsdhub!hp-sdd!hplabs!hp-pcd!uoregon!omepd!radix!jimv From: jimv@radix (Jim Valerio) Newsgroups: comp.unix.wizards Subject: Do start conditions work in lex? Message-ID: <6@radix> Date: Sat, 19-Sep-87 06:23:52 EDT Article-I.D.: radix.6 Posted: Sat Sep 19 06:23:52 1987 Date-Received: Sun, 20-Sep-87 22:48:31 EDT Reply-To: jimv@radix.UUCP (Jim Valerio) Organization: Radix MicroSystems, Beaverton, Oregon Lines: 30 Keywords: lex, bug I've been debugging a problem parsing dates in MH mail, and have narrowed it down to the point where it looks like lex is not doing the right thing with start conditions. I'm having this problem on a System Vr3 80386 system, and have reproduced the problem on a 4.3bsd Vax system. Here's a trivial lex file that illustrates the problem I am having: %{ #undef input char *inpstr = "01"; input() { return *inpstr++; } yywrap() { return 1; } main() { yylex(); } %} %start Z %% 0 { printf("0\n"); BEGIN Z; } 1 { printf("shouldn't get here!\n"); } 1 { printf("1\n"); } . { printf("Error! (%c)\n", yytext[0]); } When I compile and run this, I get the "shouldn't get here!" message from processing the the "1" digit in the fixed input string "01". My understanding of lex leads me to believe that I should instead get the output lines "0" and then "1". Am I missing something obvious here, or is there a bug in lex? If it is a bug, can someone suggest a reasonable workaround? -- Jim Valerio {verdix,intelca!mipos3,intel-iwarp.arpa}!omepd!radix!jimv