Re: Two pass compiler using YACC?

mkie@vlsivie.at (Inst.f.Techn.Informatik)
23 Aug 90 11:08:58 GMT

          From comp.compilers

Related articles
Two pass compiler using YACC? wsineel@info.win.tue.nl (1990-08-22)
Re: Two pass compiler using YACC? mkie@vlsivie.at (1990-08-23)
Re: Two pass compiler using YACC? tbr@virgil.tfic.bc.ca (1990-08-24)
Re: Two pass compiler using YACC? bart@videovax.tv.tek.com (Bart Massey) (1990-08-25)
Re: Two pass compiler using YACC? sja@sirius.hut.fi (1990-08-25)
Re: Two pass compiler using YACC? meissner@osf.org (1990-08-27)
Two pass compiler using YACC? jar@florida.eng.ileaf.com (1990-09-02)
Two pass compiler using YACC? meissner@osf.org (1990-09-06)
| List of all articles for this month |

Newsgroups: comp.compilers
From: mkie@vlsivie.at (Inst.f.Techn.Informatik)
Keywords: yacc, parse, question
Organization: Technical University of Vienna, AUSTRIA
References: <1364@svin02.info.win.tue.nl>
Date: 23 Aug 90 11:08:58 GMT

In article <1364@svin02.info.win.tue.nl>, wsineel@info.win.tue.nl (e.vriezekolk) writes:
> The problems come during link-time, for ld, obviously, complains about
> multiple defined symbols (such as yylval and yyparse).
>
> This must be a traditional problem. How is it solved?
The symbols which make you clash can be renamed by a simple sed
script
sed -e 's/yyparse/something_parse/g' \
        -e 's/yylex/something_lex/g' \
        -e 's/yylval/something_lval/g' \
        -e 's/YYSTYPE/something_TYPE/g' \


  [...] you get the idea.
You will also have to modify the y.tab.h file and the file with
yylex()


> [I hope the grammars for the two passes are the same, and just the { }
> actions are different. I always do the obvious thing, if(pass1)... else ...
> in the action routines. In about half the cases, the action routines do
> something simple like look up an identifier in the symbol table, so the
> conditional code is buried in the lower level routine. Having separate yacc
> grammars seems to me to be a poor idea if for no other reason than that it is
> a big problem to keep the two files in sync when you make a grammar change.
> -John]
That's the way I do it also, but sometimes you need two parsers in the
same executable, so this problem does exist at times


bye,
mike


Michael K. Gschwind mike@vlsivie.at
Technical University, Vienna mike@vlsivie.uucp
Voice: (++43).1.58801 8144 e182202@awituw01.bitnet
Fax: (++43).1.569697
[Similar suggestions from zs@munginya.cs.mu.OZ.AU (Zoltan Somogyi),
jouvelot@brokaw.lcs.mit.edu (Pierre Jouvelot), and vramsey@NCoast.ORG
(Cedric Ramsey).]


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.