[antlr-interest] Yacc to antlr guide?

mzukowski at yci.com mzukowski at yci.com
Fri Nov 14 12:10:19 PST 2003


See http://www.javadude.com/articles/lalrtoll.html for general LALR to LL
hints, but doesn't talk about precedence.

Precedence you will have to work out the LL way with lots of little rules.
Ter's tutorials cover this, I'm sure.

> is there some way to say that all rules 
> return a T without decorating each of them individually?

Only by modifying the code generator or by writing an ANTLR to ANTLR source
to source transformation that adds that to every rule.

Monty

-----Original Message-----
From: Christopher Nebel [mailto:c.nebel at apple.com] 
Sent: Friday, November 14, 2003 12:50 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Yacc to antlr guide?

Is there documentation somewhere on how to translate yacc grammars into 
antlr?  I've got a non-trivial yacc-based grammar I'd like to port.  
Most of the basic grammar parts are straightforward, if tedious, but 
I'm having two specific problems:

1. How do I deal with operator precedence?  The yacc grammar uses 
precedence declarations, and I don't see any equivalent.  Obviously, I 
could break the big rules apart into smaller ones that reflect the 
precedence, but I'm hoping for something more direct.

2. The actions in the original make heavy use of $[$12...], and it's 
not clear to me how to deal with that.  Well, it kind of is.  I can see 
the "rule returns [T v]" bit, but I'm not looking forward to adding 
that to every single rule -- is there some way to say that all rules 
return a T without decorating each of them individually?  The custom 
AST stuff is also sort of applicable, but I've got a bunch of weird 
constraints (notably the fact that the type is *not* a C++ object) that 
make using it somewhat impractical.

Thanks,

--Chris Nebel


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list