Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Creating an Interpreter?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Creating an Interpreter?

    I was given an assignment to create an interpreter which will read whatever the user types in and then take that and compile it into java and then print that out to the counsle. I have no idea where to start and this project is do next week. Any ideas on how to get started?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Creating an Interpreter?

    If you can, you can create a new Java file, then invoke the javac compiler If you want a true interpreter, that will be a bit more difficult (well, bit is an understatement). I would recommend using a Compiler compiler if you're allowed Otherwise, you'll probably want to implement something like the Shunting Yard Algorithm to get expressions into post-fix notation, then use an interpreter to execute the Java commands one-by-one. I'm working on one right now (well, kind of, it's on hold while I work on my classwork).

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Creating an Interpreter?

    Creating a java file and calling the compiler sounds like what an editor does. But if your assignment is more than that, there is no way one person could do it in a few days.

    Can you post some more details on what you are to do?
    What can a user try in for example?
    Compile that to java? Is there a higher level language that your program "compiles" into java source?

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Creating an Interpreter?

    Looks more like a code generator assignment to me.

    db

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating an Interpreter?

    basically this is the assignment and scoring requirements:

    Objective:
    Create an interpreter. Your interpreter should ask you for one instuction at a time. If the instruction is "end" the interpreter should finish and print the entire program in Java with tabs.

    Example:
    int x
    set x = 4
    print "value is " + 4
    if x ==4
    print "neat"
    else
    print "not neat"
    end if end

    user can input strings until the string end is entered. Program reads the first word of a string and determines what to do next. Program saves each string (motified if needed) in a dynamic array. Dynamic array will re size by one cell each time a new instruction is added.

    types of instructions:
    print
    set
    end
    while
    if
    else
    end if
    end while
    int
    double
    String
    boolean
    char

    Any ideas at all where to start?

Similar Threads

  1. creating a package
    By x3rubiachica3x in forum Object Oriented Programming
    Replies: 6
    Last Post: September 26th, 2010, 11:10 PM
  2. Creating a bufferedimage!
    By Vexst in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: June 16th, 2010, 08:05 AM
  3. BrainF*** interpreter
    By helloworld922 in forum The Cafe
    Replies: 1
    Last Post: April 29th, 2010, 02:36 PM
  4. Need help creating this program
    By ixjaybeexi in forum File I/O & Other I/O Streams
    Replies: 25
    Last Post: October 19th, 2009, 07:08 AM
  5. creating a gui
    By rsala004 in forum AWT / Java Swing
    Replies: 2
    Last Post: July 21st, 2009, 02:17 AM

Tags for this Thread