Date: Fri, 6 Dec 1996 17:48:48 -0700 (MST) From: Ade Barkah <mbarkah@hemi.com> To: rb@gid.co.uk (Bob Bishop) Cc: terry@lambert.org, hackers@freebsd.org Subject: Re: Yacc -p<NAME> is broken Message-ID: <199612070048.RAA12021@hemi.com> In-Reply-To: <v01540b01aece468c5e17@[194.32.164.2]> from "Bob Bishop" at Dec 6, 96 09:59:34 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 - <http://www.hemi.com/> -------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612070048.RAA12021>
