Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cca!mirror!rayssd!raybed2!applicon!bambi!garrity!garrity From: garrity@garrity.applicon.UUCP Newsgroups: comp.unix.questions Subject: Re: Any LEX gurus? Message-ID: <35800010@garrity> Date: Thu, 13-Aug-87 09:50:00 EDT Article-I.D.: garrity.35800010 Posted: Thu Aug 13 09:50:00 1987 Date-Received: Sun, 16-Aug-87 23:13:31 EDT References: <1031@ius1.cs.cmu.edu> Lines: 43 Nf-ID: #R:ius1.cs.cmu.edu:-103100:garrity:35800010:000:1701 Nf-From: garrity.applicon.UUCP!garrity Aug 13 09:50:00 1987 >> I am using (trying to use) LEX (& YACC, of course) to write a parser >> for a language, and I'm running into problems defining some regular >> expressions that need to be fed to LEX. In short, everything was >> going fine and I had my parser working 'til I remembered that I >> needed to completely ignore all preprocessor directives. Well.. >> I thought that I could tell LEX to toss out all the preprocessor >> directives, much the same way I was discarding comments: >> >> \{[^\n\}]*\}? { ; /* Toss out comments */ } >> >> The problem here is that (as you'll note) this expression cannot cope with >> comments that contain newlines (which is fine, since neither can the >> compiler 8^), and for the LIFE of me, I CANNOT write an expression >> that WILL accept similar preprocessor directives that NEED to contain >> newlines. In short, I need to nuke lines that have "??" as the first >> non-white character of a line, and ending somewhere down the code >> a bit with another matching "??". I've tried things similar to: >> >> > > What I've done in simuliar situations is to detect the first "??" then >call a routine to scan to the next "??". Here's an example : Why don't you just use a start condition? This is exactly the sort of thing they are great at. Just do this. %START COMMENT %% "?"?" BEGIN 0; . ; "?"?" BEGIN COMMENT; . ECHO; -- Mike Garrity -- -- snail: Applicon, a division of Schlumberger Systems, Inc. -- 829 Middlesex Tpk. -- P.O. box 7004 -- Billerica MA, 01821 -- -- uucp: {allegra|decvax|mit-eddie|utzoo}!linus!raybed2!applicon!garrity -- {amd|bbncca|cbosgd|wjh12|ihnp4|yale}!ima!applicon!garrity