Hi Andreas,

 

Make the actions in your tree grammar call virtual/abstract functions. Then 
derive a new all-code class from the tree grammar class that overrides those 
functions to provide the action implementation. The ANTLR Tool itself uses this 
pattern in the AssignTokenTypesWalker tree grammar.

 

Sam

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Andreas Meyer
Sent: Friday, February 06, 2009 1:01 PM
To: [email protected]
Subject: [antlr-interest] Composing tree grammars

 

Hi!

 

I am using ANTLR 3.1 and I want to compose tree grammars in a way, that I have 
one "base" grammar that contains all rules, in order to define a traversal, but 
without actions/rewrites. Then, a second grammar imports the "base" grammar, 
and overrides only some rules. Now, if I try to use the second grammar on the 
input, the ANTLR runtimes complain about mismatched input: it seems that 
internally, the walker does not consume enough tokens, so that it expects the 
tokens "behind" the current token. FYI, I used the java/simplecTreeWalker 
example from the antlr 3.1 distribution and basically copied the walker, 
spelled "import ..." and removed all but one rule from the copy.

 

Did I use composite tree grammars in a wrong way? If so, how can I define 
multiple tree grammars for only small parts of the grammar?

Andreas Meyer
Developer
_____
smartShift
smartShift GmbH
Willy-Brandt-Platz 6
68161 Mannheim
T +49 (0)621 / 400 676-09
F +49 (0)621 / 400 676-06
E: [email protected] <mailto:[email protected]> 

smartshift.de <http://www.smartshift.de/> 

Information contained in this message is confidential and may be legally 
privileged. If you are not the addressee indicated in this message (or 
responsible for the delivery of the message to such person), you may not copy, 
disclose or deliver this message or any part of it to anyone, in any form. In 
such case, you should delete this message and kindly notify the sender by reply 
Email. 
Opinions, conclusions and other information in this message that does not 
relate to the official business of smartShift shall be understood as neither 
given nor endorsed by it.

 



__________ Hinweis von ESET Smart Security, Signaturdatenbank-Version 3834 
(20090206) __________

E-Mail wurde geprüft mit ESET Smart Security.

http://www.eset.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to