开发者

Generate AST for Java with ANTLR

As far as I know, there are two mechanisms in ANTLR for building abstract syntax trees. I want to buil开发者_运维技巧d a AST for Java source files.

Question: There are so many grammar rules in Java.g (java specification), it's a large work if I specify the AST generating rules for every item in Java.g. So I wondering if there is a ready-made one, and where can I get it.


This Java 1.5 grammar1 from the ANTLR Wiki generates an AST and also provides a tree grammar2.

  1. Java.g
  2. JavaTreeParser.g

22 Aug 2014 - UPDATE

Since the original link appears to be dead, the grammar and tree grammar are available in a public Gist: https://gist.github.com/bkiers/741125a606954b24bbf4

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜