language independent C++ grammar [was Re: [antlr-interest]
UpdatedC++ parser version 3.1 published November 2005]
Micheal J
open.zone at virgin.net
Wed Nov 23 02:50:48 PST 2005
> But, all this would be much more desirable if we could have the whole
> grammar base defined
> in a language independent way. So, is this feasible - to have
> a grammar
> which is usable
> by C++, Java, Python and other languages without having to
> hand port it
> from the C++ version
> every time David provides a new update?
>
> I notice that the examples with ANTLR are made available in several
> languages. Is there some
> particular magic that enables this automatically or is it out
> of manual
> porting efforts?
Magic?. Yes. I do believe Ter has a team of dedicated elfs punching away on
keybaords at ANTLR HQ somewhere near Lapland...... ;-)
As to the problems of supporting multiple language versions of a single
grammar, Bodgan Mitu's annotation tool (the ASP grammar guy - Anakreon I
think his name was - did an update to it) offers one way of achieving this.
You can find it here:
http://parr-research.com/share/1081982914285/annotation20040415.tgz
Anakreon's ASP grammars project is also an example of how to use the tool -
http://storm.cs.unipi.gr/~anakreon/aspa.html
Basically, it allows you to keep the grammar itself in one file and the
actions in another (one file per language). The grammar has place holders
for all the actions. You then add an extra step to your build process that
run a tool to combine the grammar template and an action template to
generate your *.g file.
Cheers,
Micheal
More information about the antlr-interest
mailing list