Results 1 to 14 of 14
Like Tree1Likes
  • 1 Post By kjkrum

Thread: parse java file

  1. #1
    emanhossny is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default parse java file

    Hello All,
    I want to parse a java file (i.e., I need write some code which understand the content of a given java file--> the name of this java file will be entered as input). Then, after my code understand the content of the given java file, map this java file into another target language or platform. the output from my code is the new file which can run on the target language or platform.

    in the current state, I want to write some code which can understand a java file and can parse its content and display it on the console.

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,898
    Rep Power
    5

    Default Re: parse java file

    Okay, good luck with that. Perhaps after studying compiler theory for a couple of years at your local university, you might be able to do this.

    NOTE: the parsing part I mean; converting Java code to another language is a pipe dream you'll never succeed at.
    Last edited by gimbal2; 02-07-2014 at 12:35 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    emanhossny is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Re: parse java file

    in shaa Allah I will reach. ur word is very Frustrating

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,898
    Rep Power
    5

    Default Re: parse java file

    No its not, just pick a project that more closely matches your skill set in stead of picking a project that is close to impossible.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: parse java file

    The question is: What you want to accomplish with this?

    You could have a look at eclipse code to see how it is done.

  6. #6
    emanhossny is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Re: parse java file

    Dear notivago,
    I already found during the search the Eclipse AST but I can't use it.
    could anyone have an example for reading the AST that is generated by the Eclipse?

  7. #7
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: parse java file

    That leaves us with the question. What do you want to do? Why do you need to do this parsing and code transformation?

  8. #8
    emanhossny is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Re: parse java file

    I want to parse a java file (i.e., I need write some code which understand the content of a given java file--> the name of this java file will be entered as input). Then, after my code understand the content of the given java file, I will map this java file into another target language or platform. the output from my code is the new file which can run on the target language or platform.

    I want to make this to allow the applications to be migrated between the different platforms.

  9. #9
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: parse java file

    If you discover a way to automatically convert one programming language to another, you'll probably win international fame. This is a very hard problem, perhaps impossible... not something someone's going to be able to tell you how to do on a forum.
    gimbal2 likes this.
    Get in the habit of using standard Java naming conventions!

  10. #10
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: parse java file

    Doing that is not THAT hard depending on your acceptance level of quality, back some years a colleage wrote a RegExp, yes a RegExp, in a week or two that would rewrite VB6 code in runnable C#, it was wiked, sick and it opened many doors to hell, but it produced runnable code that would do whatever the original code was intended to do.

    Using an abstract tree you can parse from more than one language to the same tree and back to languages too. That is something that a a compiler does too, from whatever language to machine instructions, and decompilers do the reverse from machine instructions to language.

  11. #11
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: parse java file


  12. #12
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

    Default Re: parse java file

    And of course there is YACC: https://en.wikipedia.org/wiki/Yacc

  13. #13
    emanhossny is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Re: parse java file

    ok, many thanks for these links. I will try to read it

  14. #14
    notivago is offline Heavy Coffe Drinker
    Join Date
    Feb 2014
    Location
    São Paulo, Brazil
    Posts
    29
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 04-29-2011, 10:02 PM
  2. Parse log file using java
    By mvg in forum Advanced Java
    Replies: 0
    Last Post: 07-03-2009, 11:36 AM
  3. Parse EDI File Using java
    By vaskarbasak in forum Advanced Java
    Replies: 6
    Last Post: 09-24-2008, 02:38 PM
  4. How to parse an xml file using java
    By karthik84 in forum XML
    Replies: 4
    Last Post: 09-12-2008, 09:38 AM
  5. Replies: 7
    Last Post: 05-23-2008, 03:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •