Can anybody pls help me writing c or c++ or java code for this program?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2007
Posts: 1
Reputation: honeysmiles is an unknown quantity at this point 
Solved Threads: 0
honeysmiles honeysmiles is offline Offline
Newbie Poster

Can anybody pls help me writing c or c++ or java code for this program?

 
0
  #1
May 1st, 2007
Build a hash table using chaining as the collision resoultion technique. Insertions into the hash table will correspond to declarations of variables and values in a program, searches will be requests for the value of a variable. Some variables will be local and have a narrow scope while some variables will be global.

The program will take input from a file, another program written in the omnipotent programming language BORG (Bionicly Omnipotent Resistance Grinders) and generate ouput from this program.

The BORG language has the following commands (keywords):
  • START-FINISH blocks. Indicating different scopes.
  • COM - Single line comments: Text should be ignored if on the same line
  • value = expression – Assignment statements, ie GEORGE = 122. This language is not option explicit, so the statement GEORGE = 122 will put a variable into the table and associate the value 122 with it.
  • ++ - increment operator, syntax: VARIABLE ++
  • -- - decrement operator, syntax: VARIABLE --
  • expressions, expressions are limited to unary and binary arithmatic, or variable names
  • supported operators: + - / * % ^ (plus, minus, divide, multiple, modulo, exponent)
  • PRINT – syntax PRINT expression. If the expression is a variable, and this variable is not in scope, then an error message indicating unknow variable x at line number y. The value printed if there is a variable in scope should be the variable with the closest scope.
  • errors – other than the print statements, our interpreter will not be responsible for detecting errors, syntax errors should be disregarded if encountered, assume that the source file is correct.
Our hash function: sum the ordinal values of the characters of the variable multiplied by their position in the string (1-indexing), then taking the modulo by TABLESIZE.

ie. The variable ABC = (65 * 1 + 66 * 2 + 67 * 3) % TABLESIZE

All tokens are seperated by one space or a new line.

Output: for this , run your interpreter on this sample source program as well as a program of your own, and turn it the output from both, as well as the source code from your BORG program as well as source code of the assignment and its executable. Zip is good.

may implement one additional feature to the language, such as adding if, methods, more capable print statements. Only one student may implement a given extension to the language, and each extension must first be cleared with me.

Sample program and its output:
Input

COM HERE IS OUR FIRST BORG PROGRAM

COM WHAT A ROBUST LANGUAGE IT IS

START

BORAMIR = 25

LEGOLAS = 101

PRINT BORAMIR
BORAMIR ++

PRINT LEGOLAS LEGOLAS IS 25

PRINT BORAMIR * 2
COM

COM NESTED BLOCK

COM

START

GANDALF = 49

PRINT GANDALF
PRINT BORAMIR
FINISH

PRINT GANDALF
START

LEGOLAS = 1000

PRINT LEGOLAS
FINISH

PRINT LEGOLAS
LEGOLAS --

PRINT LEGOLAS
FINISH
OUTPUT
Output






BORAMIR IS 25

LEGOLAS IS 25
GANDALF IS UNDEFINED
BOARAMIR * 2 IS 50





GANDALF IS 49
BORAMIR IS 25

GANDALF IS UNDEFINED


LEGOLAS IS 1000

LEGOLAS IS 101

LEGOLAS IS 101




CAn anybody write code for this program?

Thank uu
Last edited by honeysmiles; May 2nd, 2007 at 12:05 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,039
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Can anybody pls help me writing c or c++ or java code for this program?

 
0
  #2
May 1st, 2007
What do you need help with? Nobody's going to do your homework for you; you need to ask yourself why you can't do this yourself and then figure out specific questions that will help you to solve the problem yourself.

If you want somebody to write the whole thing for you, offer money. But even then the person might turn you in to your professor.

In fact, searching on Google gives matches at Rent-A-Coder.
Last edited by Rashakil Fol; May 2nd, 2007 at 12:02 am.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,365
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Can anybody pls help me writing c or c++ or java code for this program?

 
0
  #3
May 2nd, 2007
Originally Posted by Rashakil Fol View Post

In fact, searching on Google gives matches at Rent-A-Coder.
OMG! I didn't realize this was going on. And to think I have been working my buns off for the last 20 years when I could have been drinking a beer while letting RentACoder do my work. I would hope universities will expell any student who does that.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC