[antlr-interest] using parsetree

Sriram Durbha cintyram at yahoo.com
Fri Nov 8 08:53:19 PST 2002


hi ,
 how do i match a structure definition with initialisation inside it?

example;
 struct A 
 {
  struct B
   {
     int intinb = 9 ;  // default value
     struct C
     {
        int a[] = {1,2,3,4,5,6} ; // default value
        char b[] = "some array of chars" ; // default value
     }  ccc = DEFAULT ;  // make ccc have all default values
   } bb ; // instead of default values fill with null values 
 } aaa ; // same as for bb  


normally to mathc such a nested declaration i think stacks are used ..
so that a scope can be pushed and popped ;

but now since we have to also match the initialisation values and
assign default values too , we have to create a golden variable which
has all the default values ;
also my approach was to use the parse tree to see if the syntax of the
rhs of any initialisation is correct by using the parse tree; but now
that we have to store the values also and assign them to golden copies
so that all furthur instances of the variables can have default values
..
there are many interesting cases in this , but we get into the details
if  i can do atleast the basic recognition properly ..


so the question is 
a] how to use the parsetree during parse?
   and also how to decorate it with values during parse?
b] if you have a different approach or a suggestion to improve this
approach , please do shar eit ;

thanks
ram






 






__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

 

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



More information about the antlr-interest mailing list