[antlr-interest] problem with using 2.7.6
=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?=
sunjigang1965 at yahoo.com.cn
Sat Feb 4 17:11:03 PST 2006
Here is my grammar--
primaryExp returns [object r=null] {object e;}
:
num:INTEGER_LITERAL {r=int.Parse(num.getText());}
| "true" {r=true;}
| "false" {r=false;}
| id:ID {r=retrive(id.getText());}
|"new" "int" LSQUARE e=expression RSQUARE
{if (e is System.Int32)
r=new int [(System.Int32)e];
else
Console.WriteLine("Integer type data expected");
} //new int[3],
| "new" idd:ID LPAREN RPAREN{}// r= new idd.getText() ();} // new a()
;
Antlr 2.7.6 generates --
...
try { // for error handling
switch ( LA(1) )
{
case INTEGER_LITERAL:
{
num = LT(1);
num_AST = astFactory.create(num);
astFactory.addASTChild(ref currentAST, num_AST);
match(INTEGER_LITERAL);
r=int.Parse(num.getText());_ttype = INTL;
primaryExp_AST = currentAST.root;
break;
}
....
C# compiler reports the following statement has some invalid argument, Argument '1' should not be passed with 'ref' keyword:
astFactory.addASTChild(ref currentAST, num_AST);
The above grammar works ok with 2.7.5
Cheers
Jigang
---------------------------------
ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ
ÑÅ»¢ÖúÊÖ-ËÑË÷¡¢É±¶¾¡¢·ÀɧÈÅ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060205/72d5b109/attachment.html
More information about the antlr-interest
mailing list