[antlr-interest] default ANTLR behavior
Terence Parr
parrt at cs.usfca.edu
Wed Jun 28 16:10:58 PDT 2006
Ok, so after trying to plug in the Java from language spec and also
to convert Grimm's Rats!-based java grammar to ANTLR v3, I think the
default mode for antlr should be more forgiving. While I'm ok with
making the grammar conform to v3, the deluge of errors emitted by
ANTLR can be really discouraging. I am proposing that we start ANTLR
out with "k=1 + auto-backtracking" or PEG mode. In other words,
accept any grammar w/o error. If there is an ambiguity, ANTLR will
automatically backtrack over the alts in that decision and take the
first one that matches. The LL(1) will make it more efficient than a
normal PEG implementation. note that I do memoization so parsing is
still linear.
Then, if you want to optimize your grammar for speed, you can turn on
an "expert" mode or something that will engage full LL(*) and manual
backtracking, which does some amazing optimizations. The only
negative with LL(*) at the moment is that sometimes it hits a
"landmine" and cannot finish analyzing the decision. I suspect this
is because of my blunt indicator (raw DFA conversion time, size)
about when ANTLR has gone off into the weeds, but to ensure
acceptance of the tool I want to provide a much less intimidating
interface for the uninitiated.
The default mode would put a syn pred on every alt but of course
would only use them when LL(1) failed. You could set k=2 for the
grammar and it would backtrack when k=2 failed. So, this is like
current antlr accept you won't get any warnings, it will just
backtrack when fixed k fails. perhaps when I get more experience
with large grammars and LL(*) we can make this the default.
Thoughts and comments are appreciated.
Ter
More information about the antlr-interest
mailing list