This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

Commit 08d574d8 authored by jdev52's avatar jdev52

changed valuetype to support various types

parent ad6a7322
......@@ -7,8 +7,6 @@
#include "SymbolTableEntry.h"
using namespace std;
class SYMBOL_TABLE
{
private:
......
......@@ -2,6 +2,8 @@
#define SYMBOL_TABLE_ENTRY_H
#include <string>
#include <ostream>
#include <stdexcept>
using namespace std;
#define UNDEFINED -1 // Type codes
......@@ -19,20 +21,43 @@ using namespace std;
#define LOGICAL 11
#define RELATIONAL 12
typedef struct
union TYPE_VALUE{
char* text;
bool boolean;
int number;
};
struct TYPE_INFO
{
//value can be int, bool or str not sure how to do this correctly
int value; //place holder
TYPE_VALUE value;
// one of the above type codes
int type;
// numParams and returnType only applicable if type == FUNCTION
int numParams;
int numParams;
int returnType;
// operatorType is only applicable if production is an operator
int operatorType;
} TYPE_INFO;
friend ostream& operator<<(ostream& os, const TYPE_INFO& rhs){
switch(rhs.type){
case INT:
os << rhs.value.number;
break;
case STR:
os << rhs.value.text;
break;
case BOOL:
os << rhs.value.boolean;
break;
default:
throw std::invalid_argument("invalid type at print");
}
return os;
}
};
class SYMBOL_TABLE_ENTRY
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment