[antlr-interest] Re: How to parse java source code ?

charlweed charlweed at yahoo.com
Mon Jul 14 15:25:15 PDT 2003


I'm afraid I must disagree with the opinion that ANTLR is  "easy-to-
use" and "well documented". As to the later, the javadocs are not in  
the distribution, and are not built from the makefile. The Javadocs 
online are from the NEXT version, and are accordingly incomplete, and 
are inaccurate for 2.7.2. And you NEED the javadocs because you must 
extend the classes and write your own to  get anything done.

As for easy to use, perhaps ANTLR is easy compared to writing your 
own from scratch, but even figuring out how to use the Java parser 
example is quite difficult if you are completely new to ANTLR. It 
took me almost two work days to figure out that the Java parser 
example can't be used-out-of-the-box for doing what I ( and Suma 
Venkatesh ) want, namely parsing Java source, then processing the 
text that makes up the source. I posted a request for help on this 
topic myself ( message 8888 ), and the single response I received 
referred me to http://jazillian.com/antlr/JavaEmitter.html which may 
be what both of us originally wanted. JavaEmitter is not a small 
chunk of work, and could not be written without a thorough 
understanding of ANTLR.

ANTLR may be great, but including some more user-friendly tools, ANT 
buildfiles, and some more examples that are solutions to common 
newbie problems, would make it much easier to use.



--- In antlr-interest at yahoogroups.com, Anthony Kong 
<anthony.kong at u...> wrote:
> I guess you can take a look at http://www.antlr.org/. It is a 
reasonably
> easy-to-use parser. Well documented.
> 
> Regards,
> 
> 
> Anthony
> 
> -----Original Message-----
> From: Suma Venkatesh [mailto:sumav_99 at y...]
> Sent: Saturday, July 12, 2003 7:37 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] How to parse java source code ?
> 
> 
> Hi,
> 
>   Iam looking for a parser which can parse an input java source 
code.I 
> mean the parser
> should read
> the source code and identify the variable names and types.
> 
> Eg: Input is :
>   import java.util.*;
> 
> public class HelloWorld{
> 
> public static void main(String args[]) {
> 
> String message = "Hello World";
> int count =0;
> 
> 	while(count <10) {
>              System.out.println(message);
>              count++;
>         }
> 
> }
> 
> Output should be :
> 
> Variables: type name
>            int  count
>            String message
> 
> Can ANTLR do this and if so how ??
> 
> PLEASE HELP ME!!
> 
> thanks in advance,
> suma
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list