[antlr-interest] Don't Shoot! (Getting started w/ANTLR3 and C#)

C. Mundi cmundi at gmail.com
Wed May 14 13:30:15 PDT 2008


Thanks for asking, Hrn. Luber.  I appreciate your invitation.

I should clearly state that my observations are by no means unique to the
wiki pages describing the C# target.  Similar comments could be made about
many of the wiki pages.The difficulties I have with the wiki pages seem to
fall into a few general classes:

1. Instructions which do not clearly specify the applicable version(s) of
ANTLR.

2. Unspecified or ambiguous paths within archives.  (This challenge is
compounded when the version of ANTLR is ambiguous.)

3. This point concerns specifically the The C# Target wiki
http://www.antlr.org/wiki/display/ANTLR3/Antlr+3+CSharp+Target.  This is a
very helpful page, except that the "Status" section leaves me very wanting
to use the CSharp2 target and very wondering what  requirements I must meet
in my environment.  H. Link has commented extensively on this within the
last day.

I also wish to emphasize that I have had almost no problem with the example
grammars, which are highly informative.

Also -- and this is again a more general comment, not specific to C# -- the
ANTLR documentation is naturally very focused on Java.  I would expect the
other targets to lag the "reference" Java target.  Rapid evolution and an
active developer community make ANTLR very appealing, but may also create
some confusion for people who are new to parsing and are trying to soak up a
lot of information at once.  I'm not so easily scared, being a bit of an OSS
veteran.  But I do think there is plenty of opportunity to give newcomers
more chances to get a toe-hold, for example, by presenting a start-to-finish
example for *each* of the targets (not just C#), starting with a rudimentary
grammar and ending with the necessary dependencies for the build
environment, e.g. Visual Studio.  This would include, again, clear
definition of which version of ANTLR must be used in each case.

I will add all of the assembly references and see if that helps.  But I
think I'm still having a version-skew problem, as H. Link suggests, and you
seem to confirm.

Incidentally, if you are the author of the file describing the "what I have
to do to cut a release" of the C# target using NAnt, then I say  *Thank You*
for a document which I will definitely need.

Finally, thank you for pointing out in the wiki that ANTLRWorks can remotely
debug non-Java parsers.  I look forward to making use of this, as soon as I
have a C# parser running.

I sincerely appreciate your taking the time to help me get started with
ANTLR.

Best Regards,
C. Mundi

On Wed, May 14, 2008 at 3:43 AM, Johannes Luber <jaluber at gmx.de> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080514/5d1cbd4f/attachment.html 


More information about the antlr-interest mailing list