[antlr-interest] ANTLR version 2.X to ANTLR version 3.X (the horror, the horror)

Kay Röpke kroepke at classdump.org
Sun Aug 10 13:08:15 PDT 2008


On Aug 10, 2008, at 6:19 PM, Raphael Reitzig wrote:

> "Kay Röpke" <kroepke at classdump.org> wrote (Sat Aug  9 17:19:21 2008):
>
>> I think the main problem is that when programmers realize they need  
>> to parse something, they often want to parse very ambiguous and ill- 
>> defined languages. Creating something that "just works" is hard for  
>> those types of languages, hence the fuck-up part.
> That, of course, is a hindrance no tool can feature away. I vote for  
> language theory for everyone!
> ("Bah, what do I need computer scientists for? I can program well  
> enough myself!" a friend of mine, astrophysicist)

Aah, the physical sciences ;) Oddly enough, I remember that sentence...

>> Often I wonder if people new to ANTLR even bother to check out the  
>> "getting started" page on the wiki. It's quite disturbing to me to  
>> think they do not, because when I'm new to a tool I might start  
>> playing with it as well without reading anything about it, but once  
>> I don't understand something, I turn to articles or blogs.
> Personally, I did not follow the guidelines very closely. I began  
> directly with my original problem (it's not that hard). But I  
> realized soon I produced a mess. I then took the old-school path and  
> ordered The Book. I hope that Book >= Wiki holds? If not, future  
> editions should contain some stuff from there.

The book is a definite must-have, IMHO. However, many people  
complained about the lack of (free) documentation, but almost anything  
I was able to find either on the wiki or in the list archives.  
Granted, getting started with a new tool can be tough, but I think  
there's enough information out there to jump start people, even if  
they haven't got the book (yet).

>> I just realize that probably the biggest source of confusion are  
>> combined grammars. If a beginner does not grasp the important  
>> distinction between lexer and parser rules, it's probably best to  
>> start out with separate grammars for those. Then, all of a sudden,  
>> realization comes when you see that separation into two files. :)
> I do not understand why combined gramars exist at all. If the only  
> way to work with them properly is to separate parser and lexer rules  
> completely, well, then it doesn't matter if I have one ore two files.

I'm lazy, thus I like to actually have them in one file so I can "jump  
to definition". Other than that, I don't think there's any reason for  
it. Internally of course, they are two files :)

> Given, of course, that ANTLRWorks interprets and debugs as smoothly  
> as with combined gramars with separated ones.


It does, though I think you need to use "Debug Remote" and write the  
main class yourself. Then again, if you are not working in Java,  
that's a moot point anyway.
I tend to use "debug remote" all the time, except for the most  
simplistic grammars, because in one way or another those grammars are  
tied to my applications.
Ok, that's not entirely correct: For the latest one, I modified the  
glue code template ANTLRWorks uses, to be able to provide a case  
insensitive character stream.

cheers,
-k

-- 
Kay Röpke
http://classdump.org/








More information about the antlr-interest mailing list