=?gb2312?q?=BB=D8=B8=B4=A3=BA=20[antlr-interest]=20Adding=20Utility=20Met?=
=?gb2312?q?hods=20to=20a=20parser?=
=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?=
sunjigang1965 at yahoo.com.cn
Fri Mar 10 11:45:43 PST 2006
anywhere after your parser declaration, put your method definition in {}, e.g.
class MyParser extends Parser;
{
public void myMethod()
{
System.out.println("hello world");
}
}
...
myGrammar:
xxxx
| yyyy { myMethod();}
;
...
Jigang
--- Dave McD <davemac2 at yahoo.com>дµÀ:
> I'm not all that familiar with Java and am new to ANTLR, so this may be obvious for other folks
> here. Question: How can I add additional methods to the Parser class that ANTLR generates? I
> want to define some utlity methods that I can use in my actions within the rules. Or is there a
> better way to do this?
>
> thanks
>
> Dave Mc
>
>
>
> ---------------------------------
> Yahoo! Mail
> Bring photos to life! New PhotoMail makes sharing a breeze.
____________________________________________________
More information about the antlr-interest
mailing list