[antlr-interest] problem with ast

Matthew Ford Matthew.Ford at forward.com.au
Tue May 6 01:59:10 PDT 2003


My suggestion is

var -- a -- type

and then put this in a symbol table on the first pass with a tree walker.
Or even better put it in the symbol table stright from the parser.
I note that var a : int;  does not set a value for a or if it does it is a
default value so you do not need to
generate any output code for this variable until it is first used.  At which
point you look up the symbol
table and if it has not been allocated memory and intialized you do it then.

matthew
----- Original Message -----
From: "maciej1205" <m_kabacinski at poczta.onet.pl>
To: <antlr-interest at yahoogroups.com>
Sent: Tuesday, May 06, 2003 6:28 PM
Subject: [antlr-interest] problem with ast


> Hi,
>
> I'm trying to build aa compiler for small language ( int type, bool
> type, for , while, ..)
> ex.
>  program
> var a : int;
> var b : int;
> var c : bool ;
> begin
>  if c then b=a+b;
> end ;
> endprog;
>
> I've already build parser but without rules.
>
> problem is, I can't build ast tree for defined variables.
> my idea is to build tree :
> int_type                 bool_type
>    |                         |
>    a----value                c-----value
>    |
>    b----value
>
> Can anybody help me with this ?
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

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




More information about the antlr-interest mailing list