[antlr-interest] Re: antlr vs. sableCC comparison
Oliver Zeigermann
oliver at zeigermann.de
Sat May 24 04:19:13 PDT 2003
--- In antlr-interest at yahoogroups.com, "lgcraymer" <lgc at m...> wrote:
> My reaction to SableCC has always been, "Why?", and the answer
> always seems to be "it was a good excuse for Gagnon to have fun
> writing a master's thesis". It has less functionality than either
> ANTLR or JavaCC and was introduced after both were available.
At the time he wrote SableCC, only few *LALR* generators for Java
were around and it was yet undecided which would be the best, so he
just tried to do something good. As you said, both ANTLR or JavaCC
are *LL*.
> Predicated LL(k) (ANTLR) parsing can handle any context-free
> grammar, but LALR does not and modern versions of yacc support GLR
> parsing to get past the LALR limitation.
I think you mix something up here (or do I?). Surely neither YACC
nor SableCC nor ANTLR can handle all context free grammars! What you
wanted to say is any context free language, i.e. a language that can
be described by a context free grammar, can also be described by an
ANTLR grammar, right?
Anyway, please tell more about GLR. How does it work?
Personally, I am fan of ANTLR and LL, but still, there are some good
reasons to choose bottom up methods. Some purists like the idea of
describing a language completely by the means of a most human
readable and thus natural (hopefully context free) grammar. To use
such grammars with LL or LR methods you will have to modify them. It
turns out that LR methods need less modification of the grammar than
LL, which is considered valuable by some pepole.
> ANTLR's tree grammar approach is more powerful than the visitor
> approach. In fact, a visitor can be expressed as a special ANTLR
> tree (I've not tested this code, but it should work):
>
> visitor
> :
> ( visit )+
> ;
>
> visit
> :
> ( .
> | #( . ( visit )+ )
> )
> ;
I do not think that will work (maybe it does). How to decide between
first and second alternative of rule visit?
This will do, I think (visitor rule unchanged):
visit
:
#( . ( visit )* )
;
Oliver
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list