Re: Two pass compiler for a language similar to Java

kamalp@acm.org (Kamal R. Prasad)
7 Sep 2004 23:56:06 -0400

          From comp.compilers

Related articles
Two pass compiler for a language similar to Java joanpujol@gmail.com (=?ISO-8859-1?Q?Joan_Jes=FAs_Pujol_Espinar?=) (2004-09-03)
Re: Two pass compiler for a language similar to Java kamalp@acm.org (2004-09-07)
Re: Two pass compiler for a language similar to Java jjan@cs.rug.nl (J.H.Jongejan) (2004-09-08)
Re: Two pass compiler for a language similar to Java lhp+news@toft-hp.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen) (2004-09-13)
Re: Two pass compiler for a language similar to Java vidar@hokstad.name (2004-09-13)
Re: Two pass compiler for a language similar to Java joanpujol@gmail.com (Joan Pujol) (2004-09-13)
Re: Two pass compiler for a language similar to Java tzvetanmi@yahoo.com (2004-09-13)
Re: Two pass compiler for a language similar to Java kers@hplb.hpl.hp.com (Chris Dollin) (2004-09-13)
[1 later articles]
| List of all articles for this month |
From: kamalp@acm.org (Kamal R. Prasad)
Newsgroups: comp.compilers
Date: 7 Sep 2004 23:56:06 -0400
Organization: http://groups.google.com
References: 04-09-032
Keywords: parse
Posted-Date: 07 Sep 2004 23:56:05 EDT

Joan Jesús Pujol Espinar <joanpujol@gmail.com> wrote


> I'm doing a pseudocode language similar to Java (it is posible to use
> things before are defined).
> I know (or I think ;) ) that the best way to manage this is with two
> pass using ASTs. And is the strategy that I'm using.


A procedural language does require a 2-pass compiler.


> But only for curiosity, it's possible to do the semantic analysis of my
> language in a syntatic directed compiler with only one pass. The
> strategy will be to put in the symbol table what you are waiting to get
> and when you find the definition compare if what are you waiting is what
> is defined... It's a lot more dificult, but it's posible, or there are
> problems that I can't see?


How will you identify errors in function parameters? A symbol table
isn't the only one that needs to deal with yet-to-be-encountered
stuff.


> A lot of thanks in advance and excuseme for my little english.


If you want an interpreter -it makes sense to go in for a 1-pass
compiler. Else, 2-pass is what one would use.


regards
-kamal


Post a followup to this message

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