Welcome to Dream.In.Code
Become a Java Expert!

Join 150,153 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,364 people online right now. Registration is fast and FREE... Join Now!




NEED HELP!

 
Reply to this topicStart new topic

NEED HELP!, I WUD BE REALLY GRATEFUL FOR ANY HELP NE OF THE GUYS CUD GIVE ME..

positivecrap
4 Aug, 2008 - 10:29 PM
Post #1

New D.I.C Head
*

Joined: 4 Aug, 2008
Posts: 1

FOLLOWING IS A QUESTION THT I WUD LIK SOME HELP WITH. I NO THIS WUD BE A MINOR THING FOR LOT OF U GUYS I DO NEED HELP WITH THIS. I'M JUST A BEGINNER. SO PLZ HELP



Write an interpreter for the following language. Define and use a Procedure class that stores information about one procedure, i.e., the list of its instructions. The instructions are stored parsed: i.e., as < OPERATION-CODE, OPERANDS > tuple. You may choose any representation for op codes (but make sure that you use no literal constant in any of your methods). You need classes ProgramInstruction, OpCode and Operand. Classed Program and Procedure should each have the execute method that sequentially executes its Instructions. You will also need a VirtualMachine class (that will have your main program) as well as a Parser class. Make sure you handle exceptions (wrong input programs). The execute method for the PRINT instruction may directly call the JAVA print function.

Syntax
COMMENT string
DEFINEPROC procedurename parametername
SET variablename anothervariablename/value
ENDPROC
CALLIF variablename/value procedurename variablename/value
PRINT variablename


Details
All procedures take one input parameter and return no values
The input parameter can only be an integer (of arbitrary size)
All calls are by value
Recursion is allowed
No global variables
Only integer constants -- but of arbitrary width
Each program must have an entry procedure named "start".
CALLIF calls the function if the first operand is non-zero; the last operand provides the parameter value.

Example Code
COMMENT This is a comment DEFINEPROC recur level PRINT level CALLIF level recur level-1 ENDPROC DEFINEPROC start SET call 1 CALLIF call recur 3 ENDPROC Expected Output
3 2 1 0
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: NEED HELP!
4 Aug, 2008 - 10:32 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Other than the "assignment" what's the question? What do you need help with?

You've even been provided with sample code at the bottom.
User is online!Profile CardPM
+Quote Post

PsychoCoder
RE: NEED HELP!
4 Aug, 2008 - 10:54 PM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:34AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month