Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!mintaka!spdcc!esegue!compilers-sender From: vlsivie!mike@relay.EU.net (Michael K. Gschwind) Newsgroups: comp.compilers Subject: Re: Lexers in YACC? Keywords: yacc, lex Message-ID: <9009101344.AA20458@vlsivie.tuwien.ac.at> Date: 10 Sep 90 22:44:06 GMT Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: Michael K. Gschwind Organization: none Lines: 34 Approved: compilers@esegue.segue.boston.ma.us In-Reply-To: <26E50E36.34BE@marob.masa.com> In article <26E50E36.34BE@marob.masa.com> you write: >What I don't understand is how to make the generated parser of the first >stage "return" tokens to its caller. It seems to require generalized >co-routines, which of course C does not provide. The operating system is >Unix System V. No, you don't want to do this. Rather, I would queue the tokens, insert magic tokens (which make the grammar LALR(1)) and after the first stage call the second. Sequence works fine as long as there is no interaction. In the above scenario, there is no need for interaction. BTW, in many cases, lex is powerful enough to make a grammar lalr(1) with right context rules. You want to look into these. If these aren't sufficient, you could use start states as well. E.g., if you have to differentiate between function definitions, function declarations and variable dfinitions in C, you could use: %% {identifier}/\([^)]\) return FUNCTION_DEFINITION; {identifier}/\([^)]\); return FUNCTION_DECLARATION; {identifier} return VARIABLE; %% bye, mike Michael K. Gschwind mike@vlsivie.at Institute for VLSI-Design mike@vlsivie.uucp Technical University, Vienna e182202@awituw01.bitnet Voice: (++43).1.58801 8144 Fax: (++43).1.569697 -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.