[antlr-interest] Writing an antlr code generator

Ric Klaren ric.klaren at gmail.com
Mon Sep 5 11:29:34 PDT 2005


Tommy Nordgren wrote:
> How do i implement an Antlr code generator to support a new language?

For antlr 2 it basically boils down to copying one of the
antlr/<target>Codegenerator.java files and the action lexer stuff in
antlr/actions/<target>/ depending on what language you have to also use
some other stuff maybe just check the other codegenerators for how
things got solved. Next to the codegenerator you'll probably need some
support library code as well. Most of the other backends use pretty
direct ports of the java support library.

For antlr3 there's templates you can copy/modify to generate code. No
docs for it though since it's still a moving target. Still need to
update the C codegen since the last few changes in the java target.

HTH,

Ric


More information about the antlr-interest mailing list