Re: Two pass compiler for a language similar to Java

vidar@hokstad.name (Vidar Hokstad)
13 Sep 2004 12:28:40 -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)
Re: Two pass compiler for a language similar to Java kamalp@acm.org (2004-09-21)
| List of all articles for this month |
From: vidar@hokstad.name (Vidar Hokstad)
Newsgroups: comp.compilers
Date: 13 Sep 2004 12:28:40 -0400
Organization: http://groups.google.com
References: 04-09-032 04-09-051
Keywords: design
Posted-Date: 13 Sep 2004 12:28:39 EDT

kamalp@acm.org (Kamal R. Prasad) wrote
> 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.


Where did you get that idea from? *Some* procedural languages require
a 2-pass compilers. Many, such as Pascal, Modula 2, Oberon, C and many
more can be compiled with a single pass compiler just fine. The main
issue is whether a language requires sufficient type information to be
defined before use or not.


Sometimes single pass compilation may require less efficient code,
because you may need to use less efficient branch instructions etc. if
you don't know how far you're branching, but single pass compilers
were extremely widespread for procedural languages for reasons of
speed (of compilation, that is) and simplicity (often no need to build
a parse tree/AST).


Two pass is a more flexible choice, and more suitable the larger and
more complex you expect the compiler to get (personally I use single
pass for simple domain specific languages, but not much else), but
it's by no means a necessity for a significant subset of procedural
languages.


Vidar


Post a followup to this message

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