Question: Program Specification: Build a hash table using chaining as the collision resolution technique. Insertions into the hash table will correspond to declarations of variables and
Program Specification:
Build a hash table using chaining as the collision resolution 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 output from this program.
The BORG language has the following commands keywords:
STARTFINISH blocks. Indicating different scopes.
COM Single line comments: Text should be ignored if on the same line
VAR varName Variable Declaration, adds varName to the hash table.
variable expression Assignment statements, ie GEORGE Find GEORGE in the hash table and assign to it
increment operator, syntax: VARIABLE
decrement operator, syntax: VARIABLE
expressions, expressions are limited to unary and binary arithmetic, 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 unknown 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 indexing then taking the modulo by TABLESIZE.
The variable ABC TABLESIZE
All tokens are separated by one space or a new line.
Output: for this assignment, 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.
Example Submission:
BorgInterpretor.cpp
HelloWorld.txt
output.txt or as a comment in the cpp file
I need to make this in C All other CHegg solutions are incompleted or in Java. I want to make sure I can have this in the file:
COM HERE IS OUR FIRST BORG PROGRAM
COM WHAT A ROBUST LANGUAGE IT IS
START
VAR BORAMIR
VAR LEGOLAS
PRINT BORAMIR
BORAMIR
PRINT LEGOLAS
PRINT GANDALF
PRINT BORAMIR
COM
COM NESTED BLOCK
COM
START
VAR GANDALF
PRINT GANDALF
PRINT BORAMIR
FINISH
PRINT GANDALF
START
LEGOLAS
PRINT LEGOLAS
LEGOLAS
PRINT LEGOLAS
FINISH
and output the correct choices.Input
COM HERE IS OUR FIRST BORG PROGRAM
COM WHAT A ROBUST LANGUAGE IT IS
START
VAR BORAMIR
VAR LEGOLAS
PRINT BORAMIR
BORAMIR IS
BORAMIR
PRINT LEGOLAS
LEGOLAS IS
PRINT GANDALF
GANDALF IS UNDEFINED
PRINT BORAMIR
BOARAMIR IS
COM
COM NESTED BLOCK
COM
START
VAR GANDALF
PRINT GANDALF
GANDALF IS
PRINT BORAMIR
BORAMIR IS
FINISH
PRINT GANDALF
GANDALF IS UNDEFINED
START
LEGOLAS
PRINT LEGOLAS
LEGOLAS IS
FINISH
PRINT LEGOLAS
LEGOLAS IS
LEGOLAS :
PRINT LEGOLAS
LEGOLAS IS
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
