[antlr-interest] ANTLR 3 sources
Terence Parr
parrt at cs.usfca.edu
Sat Dec 4 09:59:50 PST 2004
On Dec 4, 2004, at 7:54 AM, Ingo Maier wrote:
> are the ANTLR 3 (alpha, beta....) sources available anywhere? Cannot
> find them on antlr.org. Is there a public CVS or (I think I read that
> you are using) perforce repository?
Howdy. I won't be releasing the sources for a while. I'd like to get
something a little more useful before releasing it.
I have to take a detour shortly to write some lectures (I've been
invited to Berkeley across the Bay next week), get antlr 2.7.5 out
(which will have a python code generator!), get out StringTemplate 2.1,
and do some heinous job-related stuff. Once I get all of java.g
working I'll put 3.0 aside for a couple of weeks probably.
Note that the new java grammar is much much more natural. For example,
you'll see natural (but highly non-LL) lexer rules like this
FLOATING_POINT_LITERAL
: DIGITS '.' (DIGITS)? (EXPONENT_PART)? (FLOAT_TYPE_SUFFIX)?
| '.' DIGITS (EXPONENT_PART)? (FLOAT_TYPE_SUFFIX)?
| DIGITS EXPONENT_PART FLOAT_TYPE_SUFFIX
| DIGITS EXPONENT_PART
| DIGITS FLOAT_TYPE_SUFFIX
;
and finally simple comment rules like:
ML_COMMENT
: "/*"
( greedy=false : . )*
"*/"
{channel=99;} // parser listens on channel 0 by default
;
The new analysis engine builds a little mini-DFA to predict which alt
will win for non-LL decisions. Only one other DFA is built for Java's
lexer, which predicts which of your token rules will succeed so you'll
see other rules such as
NUM_INT
: DECIMAL_LITERAL
| HEX_LITERAL
| OCTAL_LITERAL
;
that don't conflict at all with FLOATING_POINT_LITERAL. :)
You get all the benefits of easy grammar writing ala lex/flex, but it
still calls methods and can do recursion etc... ala LL(k) :) Woohoo!
This kicks ass. :) Oh, and it will naturally allow semantic predicates
everywhere for those really nasty nasty lexical problems. Boy do I
love parsing. :)
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list