From owner-freebsd-hackers Fri Dec 6 16:50:22 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id QAA21283 for hackers-outgoing; Fri, 6 Dec 1996 16:50:22 -0800 (PST) Received: from hemi.com (hemi.com [204.132.158.10]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id QAA21278 for ; Fri, 6 Dec 1996 16:50:20 -0800 (PST) Received: (from mbarkah@localhost) by hemi.com (8.8.3/8.7.3) id RAA12021; Fri, 6 Dec 1996 17:48:49 -0700 (MST) From: Ade Barkah Message-Id: <199612070048.RAA12021@hemi.com> Subject: Re: Yacc -p is broken To: rb@gid.co.uk (Bob Bishop) Date: Fri, 6 Dec 1996 17:48:48 -0700 (MST) Cc: terry@lambert.org, hackers@freebsd.org In-Reply-To: from "Bob Bishop" at Dec 6, 96 09:59:34 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > At 12:01 pm 6/12/96, Terry Lambert wrote: > >[...] > >In any case, with all the non-static globals, it's inlikely that > >you could safely use multiple lexers in the same program without > >seriously fixing lex. > > True, but you don't need to; as I said in my previous reply you can run a > lexer multiple times. If you want different lex rules for different phases > (I've usually found that most are common), you can use a state variable and > REJECT. REJECT is very expensive and tremendously slows down the scanner, especially used extensively in this manner. For many cases, you are better off writing the scanners by hand, and let yacc do the work (in most instances, the scanner is much more simpler than the parser anyway.) See the GDB sources on how they did this to parse multiple languages (C, Modula-2, etc.) All the variables which need to be renamed are listed, and you can see how they implement multiple yylex() functions, one for each supported language. Regards, -Ade ------------------------------------------------------------------- Inet: mbarkah@hemi.com - HEMISPHERE ONLINE - -------------------------------------------------------------------