Ayal
Ayal

Reputation: 470

How to build an ANTLR code generation target

Is there an ANTLR4 version of "How to build an ANTLR code generation target". I know there is an ANTLR3 version but it seems to be way out of date.

Upvotes: 5

Views: 2494

Answers (1)

Sam Harwell
Sam Harwell

Reputation: 99859

The only real resource at this point is the repository for the ANTLR 4 C# target. It does include a Creating Targets document, but it's not up-to-date and some sections (notably the Release Structure) is not correct. The Git history for the project shows how I implemented the C# target starting from the Java runtime.

You should note the following:

  • Despite the removal of the AST and StringTemplate features from the ANTLR runtime, the ANTLR 4 runtime is very complicated due to the addition of the ALL(*) parsing algorithm. You should be very well versed in data structures, parallel programming, the semantics of Java code, and the semantics/libraries of your target language before attempting to create an ANTLR 4 target.
  • Creation and maintenance of the C# target is tremendously simplified by using a modified version of Sharpen to automate a large portion of the Java-to-C# conversion.

Upvotes: 6

Related Questions