[antlr-interest] Targeting different runtimes with the same grammar
Matthew M. Burke
mmburke at gwu.edu
Sun May 10 13:13:53 PDT 2009
On 09/05/2009, at 7:59, Chris Lambrou <chris at lambrou.net> wrote:
>
> Is there a recommended way of writing a grammar so that it can be used
> to target different runtimes? I'd like to be able to use the same
> grammar to target both C# (for use in an ASP.NET server application)
> and in JavaScript (for use by clients). The ANTLR book is filled with
> examples of how useful it can be to embed Java code within the
> grammar, but this couples the grammar to a specific runtime, which is
> something I'm explicitly trying to avoid.
I haven't tried this yet, so I'm not sure if it will turn out to be
awkward in practice, but you could "pre-process" the grammar files with
StringTemplate to insert the appropriate, language-specific code.
Matt
More information about the antlr-interest
mailing list