Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use the MinusMinusV 4 . zip skeleton under Files in Canvas to create an interpreter for the MinusMinus language. The basic layout of the program
Use the MinusMinusVzip skeleton under Files in Canvas to create an interpreter for the MinusMinus
language.
The basic layout of the program is main that loads then executes the program, Program.h and
Program.cpp and Execute cpp which has the MinusMinus program itself with routines for going through
the program more on that later SymbolTable.h and SymbolTable.cpp for handling symbol tables for the
functions and procedure and local variables two separate tables the utility of Stack h and Stack cpp The
Execute.cpp is the only file you need to submit. That's where you will change the execute functions itis a
skeleton for now
With the execute function, remember it does an emulation of one function or procedure at a time and
needs to have passed to it the startLine where the current function or procedure starts and the number
of parameters to match the parameters with stack offsets thats how parameters are passed It will create
a local SymbolTable called locals for use for the current function or procedure. And if it needs to execute
another functionprocedure it can use the callTable to find out where the line is that started the
functionprocedure
The basic logic is to set currentLine string to the current line being executed. Then chop parts of it off.
The startParse function needs the current line number, called lineNumber, and it starts the parsing by
copying the current line into currentLine and chops the first part of it and sets first part of it chopped
to to firstPart. There are several get functions that will chop off parts of currentline and give you a usable
token: getID to get valid identifier, getS to get a string, getE to get an equation can be a simple variable
or number or an equation The boolEquation when given your locals SymbolTable will check the next
Boolean equation for you in currentLine and chop it off, of course The equation function will take the
equation in a string with the locals and give you back the result. The chopFrontBack will chop off the first
pass value of characters off of currentLine and remove any spaces at the end
I need help to fill in the execute.cpp file for MinusMinusV interpreter
execute.cpp
MinusMinusV
#include "Program.hpp
int Program::executeint startLine, int numParms
Commands code, scan;
string temp, id eq;
SymbolTable locals;
Symbol symbol;
int offset, count, value numLocals ;
int countIf countWhile x;
int skipIf, skipWhile;
bool valid, print false, function false;
int lineNumber startLine;
code startParselineNumber;
if code FUNCTION
function true;
else if code FUNCTION && code PROCEDURE
errorMsgExecute not starting at a procedure nor function";
return ;
if getIDtemp
return ;
getParmslocals numParms;
do procfunc
while errorCount && code RETURN &&
lineNumber numOfLines
code startParselineNumber;
switch code
case ASSIGN:
put in assign code
break;
case BLANK:
case COMMENT:
currentLine ; no interpreting
break;
case CALL:
put in call code
break;
case DECLARE:
put in declare code
break;
case ENDIF:
put in end if code
break;
case ENDWHILE:
put in end while code
break;
case ENDPROCEDURE:
put in end procedure code
break;
case ENDFUNCTION:
put in end function code
break;
case IF:
put in if code
break;
case INPUT:
put in input code
break;
case PRINT:
print true;
case PRINTLN:
put in printprintln code
break;
case FUNCTION: has same error as procedure
case PROCEDURE:
getIDtemp;
errorMsgtemp
cannot be defined inside another functionprocedure;
break;
case RETURN:
put in return code
break;
case UNKNOWN:
errorMsgUnknown command";
break;
case WHILE:
put in while code
break;
if currentLinelength
cout currentLine
;
errorMsgMisc characters after command";
lastly, get rid of the parmeters,
the local variables, and whiles
stack.popnumParms numLocals
countWhile;
return value;
If more info is needed let me know
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started