[antlr-interest] How to interpret object creation sentence?

=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?= sunjigang1965 at yahoo.com.cn
Wed Feb 1 17:16:10 PST 2006


 
   
  Now I want to interpret an object creation with actions in C#, source syntax like "new ClassName()",  objective code is the same, such as" ClassName aObject=new ClassName();"
   
  The first grammar is refused by C# compiler,
  createObject returns [Object o=null]
 :
 "new" id:ID LPAREN RPAREN { o= new  id.getText()+"()";} 
 ;
    
The second just return a string, e.g. "new ClassName ()",
  createObject returns [string r=null]
 :
 "new" id:ID LPAREN RPAREN{r= "new "+id.getText()+"()";}
 ;
   
  Could any ony give me an idea?
   
  Jigang

   


		
---------------------------------
¿ìÀ´ÑÅ»¢ÓÊÏä·¢ºØ¿¨£¬°Ý´óÄêÀ²£¡ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060202/01a8e6ac/attachment.html


More information about the antlr-interest mailing list