Parsing Java - Smart skiping method bodies

View: New views
1 Messages — Rating Filter:   Alert me  

Parsing Java - Smart skiping method bodies

by qadro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all!

I'm creating a reverse enineering tool (generates UML diagrams form Java classes). I found JavaCC grammar for Java language, but I need only class headers + fileds specifications and methods prototypes to be parsed. It means that theoretically I could discard the whole message body (provided that we ignore method-inside nested classes for a while) - which means that my grammar gets much simplier, don't need conditional instructions, loops, operators or even expressions. What is the best way to do this? I was thinking about to alternatives:
* force new lex state (from parser which is generally discouraged) in which I ignore the conent until I reach the end of method body
* when the block starts go through some tokens manually counting braces till the end of method body

Is any of them a good solution? If so, how exactly should I do it? Maybe still you have a better idea?
And what if I would like to interpret method-inside nested classes? Does it change the solution dramaticly?

Thanks for your attention,
I'm waiting for replies:)

regards,
qadro