javalang icon indicating copy to clipboard operation
javalang copied to clipboard

How to parse a java file?

Open DennisShaw opened this issue 7 years ago • 1 comments

For example,I want to parse a java file. src="source/test.java" But when I use tree = javalang.parse.parse(src) it failed. I am totally new at this area.Would you mind helping me?Thank you

DennisShaw avatar Oct 29 '18 07:10 DennisShaw

Hi buddy this won't work . as the parse method expects java code not the location of java code . so you should read this using

data = open("./source/test.java").read()
tree = javalang.parse.parse(data)

mvkarthikeyan avatar Feb 12 '19 12:02 mvkarthikeyan