You have a few options:

 

1.       Only build an AST in the parser, then use a tree walker to
perform your needed operations. This is the "v3" way to do it,
especially with the new filter-mode tree parsers on the way.

2.       Call virtual functions from your actions, and implement those
functions as empty stubs. Derive a class from the parser and implement
the functions as necessary. This seems to be a "v2" way to do it, as
it's used in one of the v2 grammars in the ANTLR Tool.

 

Sam

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Indhu Bharathi
Sent: Wednesday, March 04, 2009 8:44 PM
To: [email protected]
Subject: [antlr-interest] Seperating grammar and actions

 

Hi,

 

Is there a way to separate grammar and actions into two different files?
This will be helpful when multiple people are working with the same
grammar file (each might write their own actions for the same
production) and don't want to create redundant copies of the grammar
file.

 

One way I thought was to implement observer pattern. The parser will be
the subject and multiple observers can register to the same production
and do different things. Another way would be to write a tool to
separate the actions from the grammar file and reattach it. This way,
actions can be separated out and maintained in a separate file and can
be reattached when necessary and changes to grammar can be done in one
centralized file.

 

Is there any other way to do this? Any hint might be useful.

 

Thanks, Indhu

 

 


--~--~---------~--~----~------------~-------~--~----~
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