Beginner trying to pre-process Java source
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Clifton_Craig
Posted On:   Thursday, February 19, 2004 09:00 AM

Hello all, I am an ANTLR newbie with (converted from a JavaCC newbie) what seems as it should be a straight-foward requirment. I need to pre-process Java sources and add VERSION strings where they're missing and replace them where they're present in the source. I'm attempting a small prototype for feasability so that I can take this to my team as a practical use. So far I've downloaded the Java grammar from the ANTLR site llong with the the test files. I've also read through the TokenRewriting article on the ANTLR site and downloaded all of the necessary files to run it on my own. My plan is to use this approach for Java files. I've thus been able to tweak the Main program from the article to run against the Java Parser. So far I can echo out the simpl   More>>

Hello all,

I am an ANTLR newbie with (converted from a JavaCC newbie) what seems as it should be a straight-foward requirment. I need to pre-process Java sources and add VERSION strings where they're missing and replace them where they're present in the source. I'm attempting a small prototype for feasability so that I can take this to my team as a practical use. So far I've downloaded the Java grammar from the ANTLR site llong with the the test files. I've also read through the TokenRewriting article on the ANTLR site and downloaded all of the necessary files to run it on my own. My plan is to use this approach for Java files. I've thus been able to tweak the Main program from the article to run against the Java Parser. So far I can echo out the simple test files that came with the Java grammar with my output including the whitespace and comments (I modified the grammar to allow them through to the rewrite engine which I programmatically set to discard them).

The grammar is a little complex for a newbie such as myself but I believe I can pick it up with a little guidance. I've read through several tutorials on ANTLR (as well as several tutorials on JavaCC before I switched over). I'm about ready to become a calculator factory at this point. I've also went trekking through the online docs for ANTLR and I got a little lost at some points where they sound a little ambiguous. Now the big challenge, where in the grammar do I put my insert logic? I'm stuck on the field rule in the grammar which appears to use nested productions or rules (whatever they're called) and hash signs (#) coupled with square brackets in a context that was never discussed in any of the tutorials.

Can someone help me? Am I following the path of least resistance here? How can I get a deep enoguh understanding of the syntax and semantics implemented in the Java grammar to do what I need to do? Can someone walk me through what's happening in the field rule in the JavaParser grammer? Any and all help is greatly appreciated.

Thanx,
Cliff

   <<Less
About | Sitemap | Contact