[antlr-interest] Language-Neutral Actions

Scott Stanchfield scott at javadude.com
Fri Apr 15 06:37:00 PDT 2005


I'd really like to see language-neutral actions in ANTLR 3.

The basic idea is that all action code is simply calls to behavior methods
in some other object.

Depending on what target language is specified, different "glue" code is
formed to contact that other object.

This would allow a grammar to be targeted to pretty much any language.

Some old parser generators I used did things like

  foo: fee fie fo @doSomething(fee,fie,fo);

which would allow you to target it to multiple languages. The parser
generator would change @doSomething(...) into whatever was appropriate for
the target language.

I don't know that we'd want to use the same syntax (I like the {...} for
actions), but we could have a grammar option that specifies language-netrual
actions and all {...} code is assumed neutral.

Thoughts?
-- Scott






More information about the antlr-interest mailing list