[antlr-interest] ANTLR 3.0 Templates

Terence Parr parrt at cs.usfca.edu
Thu Jun 9 10:27:54 PDT 2005


On Jun 9, 2005, at 2:03 AM, Sebastian Mies wrote:

> Hi!
>
> Does anybody know if ANTLR 3.0 supports templates?
> Maybe I did not read Ter's blog right.
>
> I would like to have something like that:
>
> expr<Op,Next> : <Next> (<Op> <Next>)* { /* doing lots of changes here
> */ };
>
> plusMinus: expr<PLUS|MINUS,mulDiv>;
> mulDiv: expr<MUL|DIV,literal>;
> literal: INT | id;

Hi. :)  I don't plan on doing templates; a /lib/cpp preprocessor  
could probably do that.

For expressions, I want something a little more direct to solve the  
problem.  What I want is to allow the user to simply specify the  
operators and there associativity / precedence and let me take care  
of it.  How?  I'm not sure, but I'm not ruling out an opaque state  
machine sort of like building an LR machine inside an LL machine...   
For expressions, this may make sense.

As for "templates", the GUI will have a wizard that will allow some  
basic code generation stuff.  One of them could in fact be this  
expression generator since it's so common.

My goal is to keep antlr itself as simple as possible since it's  
already devilishly complicated on the inside to do the analysis etc...

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com



More information about the antlr-interest mailing list