[antlr-interest] Seperating Grammar and Actions..

cintyram <cintyram at yahoo.com> cintyram at yahoo.com
Sat Jan 11 08:12:51 PST 2003


hi ,
 this is with reference to the discussion on this list a few weeks ago
on the same topic. then i was of the opinion that, using an abstract
class could help. but now having dipped my fingers into mfc to write
some user interface for my translator , i have begun wondering if some
thing like message maps works for antlr too ; 
 each rule match can fire an event/message , which can be handled by
the assigned event-handler . the information on which handler handles
which event can be put in message-maps ;

when writing the grammar we can exclude all action code from the
grammar [ whose purpose is to match the input stream ( of tokens,chars
or whatever ) ], but fire events ..

how to name the events if we want to have seperate events for each
subrule ? other wise as antlr generated code now has, the name of the
rule can be the name of the event also [now it is the name of the
function ]

how to handle cases where rules return values?

also passing the matched content thru the event to the handler , can
be an implementation  decision . [ passing by copy might not be a very
attractive option etc .. ]
 
also now we will have more flexibility .. we can pass around the
grammar exclusively of the actions taken, and the handlers can be
completely  decoupled from the grammar! 

your views please,

/e
cheers
ram





 

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



More information about the antlr-interest mailing list