Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!munnari!mulga!ausmelb!ejp From: ejp@ausmelb.oz.au (Esmond Pitt) Newsgroups: comp.unix.wizards Subject: Re: Do start conditions work in lex? Message-ID: <431@ausmelb.oz.au> Date: Mon, 21-Sep-87 19:48:53 EDT Article-I.D.: ausmelb.431 Posted: Mon Sep 21 19:48:53 1987 Date-Received: Thu, 24-Sep-87 03:29:10 EDT References: <6@radix> Reply-To: ejp@ausmelb..oz.au (Esmond Pitt) Organization: Austec International Limited, Melbourne Lines: 35 Keywords: lex, bug Summary: yes In article <6@radix> jimv@radix.UUCP (Jim Valerio) writes: >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. 1. Rules with start-conditions are in effect only within that start-condition. 2. Rules without start-conditions are always in effect. 3. In the event of two rules matching the same text, the first occurring rule is chosen. 4. Therefore, rules with start-conditions must precede rules without them. If you put your rules in this order: 1 {blah} 1 {blah} you will get the desired result. There ARE bugs in lex: 1. The metacharacters ^ and $ only work at the literal beginning and end respectively of a rule; i.e. they do not work within () brackets, nor can they be put within a named rule. For example, all occurrences of ^ in the below represent the character '^', not the beginning of the line. FRED ^FRED %% FRED printf("FRED = %s\n",yytext); (^JOE) printf("JOE = %s\n",yytext); 2. Constructions like x+/xy: if you input xxxy to this it will return xxx, not x as it should. -- Esmond Pitt, Austec International Ltd ...!seismo!munnari!ausmelb!ejp,ejp@ausmelb.oz.au D