parsing a java src file

R

ron.mexico.chicago

how do i parse a java src file, specifically for this:

public class test { public static final test alpha = new test("foo",
"bar"); public static final test beta = new test("baz", "boo"); ...
[download]


so that i'm finding all local variables that match the classname, and
get the parameters that are passed to the constructor.
this is easy enough if it's all on the same line and the order is
consistent, but there might be carriage returns and the static/final
words might be interchanged.
In the above example, i'm strictly looking for:
alpha = {foo, bar}
beta = {baz, boo}

thoughts?
thanks
 
J

Jürgen Exner

how do i parse a java src file, specifically for this:

I would suppose you write a Java parser, just like for any other programming
language.

[...]
this is easy enough if it's all on the same line and the order is
consistent, but there might be carriage returns and the static/final
words might be interchanged.

Those are items that a parser will have to take into account. Where is the
problem?

jue
 
R

ron.mexico.chicago

there's no specific problem, i'm just wondering if this has been done
before, and if so , is there a spot i could take a look at it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top