What changes do I need to make to generate C++?

Peter Wells

At a very simple level, you need to set the option 'language' at file level in each of your .g files. Then run the Java antlr.Tool class as normal.

Additionally, you need to ensure that your action code is valid C++ rather than Java. There are a number of changes which this entails.

The C++ code uses reference counted classes for Tokens and ASTs (to make up for the lack of garbage collection), and you access the actual Token (or AST) by deferencing the RefToken (or RefAST) as if it were a pointer.

So, for example:
      statement : ...
         |  s:SEMI { #s->setType(EMPTY_STAT); }
         ;  // notice: ^^