• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Parser.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I need to extract all the method names in a given Java file name and would like to know some available parsers that does the same.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch and thank you for correcting the naming problem.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean using reflection on the .class files or something like JFlex/CUP on the .java files?
I would try JFlex/CUP to create a parser.
 
nateshkumar natesamudaliar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont want to use reflection.
I have a Java file which has 4 or more independent classes(say A,B,C,D) in it.
I will have the Java file name and the name of all the 4 or more classes.
Given the class name (A or B or C or D), I need the methods inside that class. This is the main objective.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main parser engines written in Java are Antlr, SableCC and JavaCC. Grammars for parsing Java source code are available for each of these on their respective web sites.
 
nateshkumar natesamudaliar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have chosen JavaCC.
I extracted EclipseJavaCC plugin. Also I have the JavaCC jar file imported in my eclipse.
I have also downloaded java1.5.jj which has the grammar for Java I guess.
I dont know how to organize these things and use it in my project to give a Java source file and do the parsing and get the method information.
Also I would like to know if it works without using Eclipse(basically without any plugin) just by using one more JAR file.
Please give some JavaCC specific explanation.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do not need any plugin to work with JavaCC (or any IDE, for that matter). There's a tutorial at http://www.engr.mun.ca/~theo/JavaCC-Tutorial/ and some further documentation on the main JavaCC web site.
reply
    Bookmark Topic Watch Topic
  • New Topic