Writing language converter in ANTLR

前端 未结 2 913
情话喂你
情话喂你 2021-01-14 18:10

I\'m writing a converter between some dialects of the same programming language. I\'ve found a grammar on the net - it\'s complex and handles all the cases. Now I\'m trying

2条回答
  •  春和景丽
    2021-01-14 18:35

    Once you have an AST, you'll need to write a tree walker that emits your program as the transformed source. You might even have an intermediate tree walker doing tree transformations depending upon the complexity of your changes.

    That said, going through an AST step, may not be the best approach.

    You might want to take a look at "Language Design Patterns" by Terrence Parr (Pragmatic Programmers). Chapter 11 addresses your type of program.

    He mentions a tool, ANTLRMorph, that might be better suited for your problem.

提交回复
热议问题