[antlr-interest] How to add SEMI to variable declaration of class?

Fan Yang <yhhf_dy at yahoo.com> yhhf_dy at yahoo.com
Thu Feb 6 07:16:34 PST 2003


Hi,

I want to preserve all whitespaces and comments for java code, so I 
have to modify java.g and java.tree.g in order to let all SEMI be 
added to the result AST tree.

But I was stuck in how to add SEMI to variable declaration in the 
class(data member declaration). 

Because Variable declarations of class appear in the "field" rule, 
this rule suffixed with "!" means subtree will not link into a result 
tree, so the SEMI in the subrule of "v:variableDefinitions[#mods,#t] 
SEMI" will not incorporate into the result tree. I have tried to add 
SEMI into "variableDefinitions" subrule, but it seems to do a lot 
modification which are beyond my ability to do that.

Would please help me to deal with this problem. Thank you very much.

Good Wishes,

Fan Yang



----  fraction of Java.g ---
classBlock
 : LCURLY!
   ( field | SEMI! )*
   RCURLY!
   {#classBlock = #([OBJBLOCK, "OBJBLOCK"],#classBlock);}
 ;

field!
 : // method, constructor, or variable declaration
          .
          .
          .
   | v:variableDefinitions[#mods,#t] SEMI
     //{#field = #(#[VARIABLE_DEF,"VARIABLE_DEF"], v);}
     {#field = #v;}
          .
          .
          .


 

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



More information about the antlr-interest mailing list