[antlr-interest] Don't Shoot! (Getting started w/ANTLR3 and C#)
Johannes Luber
jaluber at gmx.de
Wed May 14 03:43:44 PDT 2008
C. Mundi schrieb:
>
> Ok. I have been reading the wiki and experimenting with ANTLRWorks
> while waiting for the book to arrive in my mailbox.
>
> I'm not sure the book will (or should) answer this. I am looking for a
> start-to-finish example targeting C#. The finish line for me is _not_
> the output of ANTLR. My finish line is a Windows dll or exe that
> actually parses user input.
There are example grammars for C# on the download page.
>
> I am already able to generate lexing and parsing code for various
> targets, either with ANTLRWorks or with ANTLR from the Linux command
> line. Ultimately I need to build Windows apps, so I need to get the
> ANTLR environment set up for Dev Studio. So, newly emboldened by my
> success on Linux, I tried to port my new skills to Windows by gamely
> adding an option{ language=CSharp; } phrase. Oh, if only it were so
> easy! I got C# code, but I couldn't build it.
>
> So I read a number of semi-mutually-contradictory-and-or-incomplete
> helpful hints on the wiki and by Googling.
Can you describe where you found not-as-helpful-information on the wiki,
so I can fix it?
>
> That got me as far as adding a Reference to the Antlr3.Runtime -- huge
> step forward.
I'm not sure when which assemblies are required, but I always add
Antlr.Runtime, Antlr.Utilities, antlr.runtime and Antlr.StringTemplate.
With these you cover all bases.
>
> Then I ran into this mysterious RecognizerSharedState object in the C#
> target. Uh oh. I guess I'm still missing a Reference to a .NET
> Assembly, which probably means I skipped an important step, like
> building it. I get a vague sense of this from some of the postings, but
> I guess I'm just dense.
>
> Any clues will be greatly appreciated. I'll be happy to wait for the
> book to arrive, if it has the answer. Please be blunt. Insults can
> only make me smarter. :)
My guess is that you are mixing code generation from ANTLR 3.1b1 with a
library from 3.0.1. They aren't even source compatible. Please use the
library and generation from the latest build - otherwise they may not
work together.
Johannes
More information about the antlr-interest
mailing list