[antlr-interest] Five minute introduction to ANTLR 3
Johannes Luber
jaluber at gmx.de
Fri Jul 18 11:33:22 PDT 2008
rkevinburton at charter.net schrieb:
> No, I didn't generate the grammar. Is expr() a method of the Parser class or specific to this grammar? In general what starts the parser.
You need to use the grammar to generate source code files - this is how
ANTLR works. Each grammar has a start rule - in the example's case it is
expr(). expr() is defined in the parser class generated by ANTLR. In
case you don't use the beta but 3.0.1 change the language option from
CSharp2 to CSharp. You might want to pick up the ANTLR book to really
get in depth with it - as well a book about C#. Apress has some nice C#
books available.
>
> My "driver" is a C# program that passes a file name to the action specified. I renamed Main to Parse and I passed the argument (the file name) to that function.
Each and every program requires a Main method, or it won't compile. It
is also not enough to pass a string containing the file name to the
expr()-method (which doesn't take parameters anyway). I suggest to look
for the examples on the download page and study how they work. Then copy
the appropriate code into your project. If you are still stuck then
write again!
Johannes
P.S.: Please be aware that you have to use the "Reply All" button in
your email program or you will send emails directly to me and not to the
list.
>
> Kevin
>
> ---- Johannes Luber <jaluber at gmx.de> wrote:
>> rkevinburton at charter.net schrieb:
>>> I am new to ANTLR so I was reading the 'Five minute introduction to ANTLR 3' and it contains the following:
>>>
>>> parser.expr();
>>>
>>> Which when I try to compile C# indicates that expr is not a member of the parser object. What method should I use?
>>>
>>> Thank you.
>>>
>>> Kevin
>>>
>> Did you copy the right grammar from the introduction? Do you use 3.1b2?
>> Did you generate the grammar,too? What's your driver program?
>>
>> Johannes
>
More information about the antlr-interest
mailing list