Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!columbia!rutgers!umnd-cs!jwabik From: jwabik@cs.D.UMN.EDU (Jeff Wabik) Newsgroups: comp.unix.questions Subject: Any LEX gurus? Message-ID: <716@umnd-cs.D.UMN.EDU> Date: Fri, 7-Aug-87 17:09:30 EDT Article-I.D.: umnd-cs.716 Posted: Fri Aug 7 17:09:30 1987 Date-Received: Sun, 9-Aug-87 05:50:02 EDT Organization: U. of Minnesota-Duluth, Computer Science Lines: 46 Keywords: Ack! 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: ^{WS}*"??"(.|{WS})*"??" { Where {WS} is defined as whitespace (i.e. \n, \t, ' ') } Which, of course, doesn't work since the (.|{WS})* eats everything to the end of the file and LEX segment faults.. I've also tried things like: ^{WS}*"??"[^"??"]"??" Which in my mind should work, but doesn't.. Arg. My problem is lack of documentation, since all I've got to work from is the "Compiler Construction under UNIX" book by Schreiner and Friedman.. Good book, but .. Any help would be greatly appreciated and would be responsible for retaining a fellow netter's sanity. Thanks! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-= Jeff A. Wabik University of Minnesota, Duluth 55812 ARPA: jwabik@cs-gw.d.umn.edu UUCP: {umn-cs!umnd-cs-gw!jwabik} Live long and program. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-