Wednesday 15 February 2012

parsing - Identify methods,variable, method calling in a java piece of code -


Actually I want to list all the method / variable declarations, all applicable method (s) etc. The piece of code can be completed or maybe it's just a line.

My first approach was to regax. We covered about 70% of the cases, but still this is not effective and the worst languages ​​are not regular.

I have also tried, and some other techniques But I can not promise that the piece of code will be compiled. Therefore, the above mentioned methods failed.

Is there any way to parse the code / tool / API code without compiling it or do I need to make my paras? If I have to, how can I help the eclipse / Netbeen parser? Or call the hierarchy?

EDIT: To reduce it, how can I get it in Java?

You have something that can read all the source text of the code on which your piece is dependent (Java compiler will not do this, it will be cultured on one source file at a time), and some that will parse Java code pieces (JavaC and most parser generators will not do this). You want actually "not writing your parser"; That's a lot more than your idea. Now Java is not an easy language to parse, and if you succeed, you will know that you have not dealt with at all.

What do you want reinforcing parser is designed

DMS / JFE can read all the files for a larger Java source application (and its class file ) Support AST for source code, and complete symbol table data for all defined elements and class files in source code, including A-Use-B-by-mention for each declaration A. You probably have to calculate

To handle a code piece, you can use the ability to explain DMS well, to close X-Inherits-Y (collected by JFE) To set A-B-B for For non-terminal and its use in expression (expression, statement, method, declaration) in language, call the Resolver for JFE on that piece. To get the correct answer you probably have to provide some reference data ("You'll see this piece inside the law inside the class C").

OK, so this is possible. It's not easy; DMS is a complex system because people want complex work on complex languages ​​in complex situations. To achieve this value, efforts have to be made to learn to use DMS. But it is easier than trying to roll it together with scratch or unrelated bits by itself.

If you want a short-term answer, then maybe you have a bad reg box.


No comments:

Post a Comment