开发者

Writing ANTLR grammar for parsing java file

I am new to ANTLRWorks and I am doin开发者_JAVA技巧g my final year project. Could anyone please help me in how to write ANTLR grammar just for recognising a class in java "and printing it in any file as an output". On the same lines then I will be able to write the grammar for my project.


Creating all required java classes from grammar.

Execute
java -cp antlr-3.3-complete.jar org.antlr.Tool Java.g

OR

java -jar antlr-3.3-complete.jar Java.g

from the directory where you have antlr-3.3-complete.jar and Java.g file.

Java Grammer which is compatible with Java 1.3 to 1.6

This Page explains how to use Java.g file and compile it into JavaParser and JavaLexer which are required classes to generate AST tree

Reference Resources:

This exaplains how can we generate AST Tree

This explains how can we create parser and generate AST tree for any Java class. It also explains what we need to modify in original grammar file Java.g

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜