// interp.cpp Dave Reed 10/20/03 // // This simple interpreter reads and executes SILLY programs. // Currently, it handles assignments and output statements. /////////////////////////////////////////////////////////////////////////////// #include #include #include "Token.h" #include "Tokenizer.h" #include "VarTable.h" #include "Statement.h" using namespace std; int main() { string filename; cout << "Enter the program file name: "; cin >> filename; Tokenizer program(filename); VarTable variables; Statement * stmt = Statement::GetNext(program); if (stmt == NULL || stmt->GetType() != BEGIN) { cout << "SYNTAX ERROR: missing begin" << endl; exit(0); } stmt = Statement::GetNext(program); while (stmt != NULL && stmt->GetType() != END) { stmt->Execute(variables); stmt = Statement::GetNext(program); } if (stmt == NULL || stmt->GetType() != END) { cout << "SYNTAX ERROR: missing end" << endl; exit(0); } return 0; }