Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!spdcc!m2c!frog!john From: john@frog.UUCP (John Woods, Software) Newsgroups: comp.unix.wizards Subject: Re: Do start conditions work in lex? Message-ID: <1635@frog.UUCP> Date: Tue, 22-Sep-87 20:59:00 EDT Article-I.D.: frog.1635 Posted: Tue Sep 22 20:59:00 1987 Date-Received: Fri, 25-Sep-87 06:45:51 EDT References: <6@radix> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 27 Keywords: lex, bug Summary: Yes, so does precedence In article <6@radix>, jimv@radix (Jim Valerio) writes: > %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]); } > Two keys from the LEX documentation: (1) Rules with no start condition are always active. (2) When two rules match the same input string, the first is preferred. Try changing your rules to %start Z %% 0 { printf("0\n"); BEGIN Z; } 1 { printf("1\n"); } 1 { printf("shouldn't get here!\n"); } . { printf("Error! (%c)\n", yytext[0]); } -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu Maybe it's the sound of a WET RAG hitting a smooth WEASEL!