[antlr-interest] Separation of specification and code

Monty Zukowski monty at codetransform.com
Mon Mar 7 08:43:26 PST 2005


Ken Weinert wrote:

 > I've been an antlr advocate since it was pccts (Hi Terence :) but I've
 > not really had occasion to use it much since then.
 >
 > My boss stopped by today with a question that I'm relaying here as I'm
 > really not familiar enough with the mechanics to know if antlr
 > supports this mode of operation.
 >
 > What he'd like is to be able to keep the specification clean and the
 > code separate. He mentioned Grammatica which uses the EBNF to produce
 > a parser, but you implement the actions by extending the class for
 > each leaf in the generated code.
 >
 > Have I made myself clear? Is this something that antlr supports?
 > Pointers to where I can easily resolve this are as (if not more)
 > welcome as direct answers.
 >
 > Thanks for any information.
 >

Well, are you talking just about making a parser or are you talking 
about a translator?

Somebody wrote a "literate programming" system for ANTLR which is all 
about keeping the action code separated from the .g file.  A web search 
should turn it up, it may be on the antlr.org file sharing page as well.

If you are talking about a translator, grammar subclassing is another 
approach.  http://www.codetransform.com/fun_with_antlr.html has a few 
details about managing an eight pass translator.

Monty
www.codetransform.com


More information about the antlr-interest mailing list