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 2 of 2

Thread: Need help to write an interpreter in Java

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Need help to write an interpreter in Java

    Hi Everyone,

    I need your help to develop an interpreter with given specs below. Can you guide me how start with this? I'm not that good in Java and our instructor requires us to to do this java. Do you think this is possible in Java? My deadline will be next week...till now im not able to figure out how will i do coding for this. ..


    Input should look like this:
    MYCODE

    CREATE
    FLOAT x is 0.00
    STRING str is $Hello World$
    FLOAT y is 0.00
    FLOAT res is 0.00
    END

    BRAINPOWER
    ASKVALUE x
    ASKVALUE y
    DISPLAY $ The sum is :$
    GIVEMORE ADD x y
    GIVE result
    END

    MYCODE



    The out put should be

    /* assuming x = 10 and y = 0 */
    Hello World
    The sum is 10


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help to write an interpreter in Java

    I don't see that the example is complete/correct. Where does the code do anything with str?

    One step would be to define the syntax of the language, the types of statements and the data types.
    Then write a parser that reads the source, parses and executes each statement.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help with creating a Program class for a BASIC Interpreter in Java
    By sampsoninc916 in forum Java Theory & Questions
    Replies: 1
    Last Post: February 15th, 2013, 07:04 AM
  2. Replies: 2
    Last Post: January 25th, 2013, 09:54 PM
  3. Creating an Interpreter?
    By tapp13 in forum Java Theory & Questions
    Replies: 4
    Last Post: October 11th, 2010, 05:25 PM
  4. BrainF*** interpreter
    By helloworld922 in forum The Cafe
    Replies: 1
    Last Post: April 29th, 2010, 02:36 PM