[antlr-interest] Two pass semantic analysis

Joan Pujol joanpujol at gmail.com
Tue Aug 17 00:32:29 PDT 2004


Hi,

I'm writing a compiler for a language similar to Java. It can have
recursive function calls  (A calls B and B calls A), and the same for
classes attributes. And I haven't prototypes like C++.

Do I need obligatorily a two pass compiler to manage the types, don't I?

I have thought this strategy:

I'm using ASTs,

1pass to the AST: When I find a type that I don't know I put it in the
symboltable as unknow type.
And when I find a type that has previosly entered as unknow type I
change the unkow to the type that I have found.
And at the finish of 1pass I have all type ok, haven't it?

2pass: Do the type checking.

Is this a good way to manage this, or is a better strategy?

Cheers,




-- 
Joan Jesús Pujol Espinar


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list