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.

...
 
Commits (2)
......@@ -17,15 +17,10 @@ using namespace std;
#define STR_OR_BOOL 6
#define INT_OR_STR_OR_BOOL 7
#define NOT_APPLICABLE -1
typedef struct
{
int type;
// one of the above type codes
int numParams;
// numParams and returnType only applicable if type == FUNCTION
int returnType;
} TYPE_INFO;
#define ARITHMETIC 10
#define LOGICAL 11
#define RELATIONAL 12
class SYMBOL_TABLE
{
......@@ -61,6 +56,16 @@ public:
else return(true);
}
SYMBOL_TABLE_ENTRY getEntry(string theName)
{
return hashTable.find(theName)->second;
}
int count()
{
return(hashTable.size());
}
};
#endif // SYMBOL_TABLE_H
......@@ -6,26 +6,53 @@ using namespace std;
#define UNDEFINED -1
typedef struct
{
// one of the above type codes
int type;
// numParams and returnType only applicable if type == FUNCTION
int numParams;
int returnType;
// operatorType is only applicable if production is an operator
int operatorType;
} TYPE_INFO;
class SYMBOL_TABLE_ENTRY
{
private:
// Member variables
string name;
int typeCode;
TYPE_INFO typeInfo;
public:
// Constructors
SYMBOL_TABLE_ENTRY( ) { name = ""; typeCode = UNDEFINED; }
SYMBOL_TABLE_ENTRY( ) {
name = "";
typeInfo.type = UNDEFINED;
typeInfo.numParams = UNDEFINED;
typeInfo.returnType = UNDEFINED;
}
SYMBOL_TABLE_ENTRY(const string theName, const TYPE_INFO theType) {
name = theName;
typeInfo.type = theType.type;
typeInfo.returnType = theType.returnType;
typeInfo.numParams = theType.numParams;
}
SYMBOL_TABLE_ENTRY(const string theName, const int theType)
{
SYMBOL_TABLE_ENTRY(const string theName, const int type = UNDEFINED,
const int numParams = UNDEFINED, const int returnType = UNDEFINED){
name = theName;
typeCode = theType;
typeInfo.type = type;
typeInfo.returnType = numParams;
typeInfo.numParams = returnType;
}
// Accessors
string getName() const { return name; }
int getTypeCode() const { return typeCode; }
TYPE_INFO getTypeInfo() const { return typeInfo; }
};
#endif // SYMBOL_TABLE_ENTRY_H
......@@ -23,7 +23,7 @@ test_files=`ls ./sample_input`
diff_files=0
for file in $test_files; do
mfpl < ./sample_input/$file > ./my_output/$file.out
./mfpl < ./sample_input/$file > ./my_output/$file.out
diff_lines=`diff ./my_output/$file.out \
./expected_output/$file.out \
......
......@@ -29,151 +29,124 @@ COMMENT ";".*
{COMMENT} {}
"let*" {
printToken("LETSTAR", yytext);
beginScope();
return T_LETSTAR;
}
"lambda" {
printToken("LAMBDA", yytext);
beginScope();
return T_LAMBDA;
}
"input" {
printToken("INPUT", yytext);
return T_INPUT;
}
"print" {
printToken("PRINT", yytext);
return T_PRINT;
}
"if" {
printToken("IF", yytext);
return T_IF;
}
"exit" {
printToken("EXIT", yytext);
return T_EXIT;
}
"progn" {
printToken("PROGN", yytext);
return T_PROGN;
}
"(" {
printToken("LPAREN", yytext);
return T_LPAREN;
}
")" {
printToken("RPAREN", yytext);
return T_RPAREN;
}
"+" {
printToken("ADD", yytext);
return T_ADD;
}
"*" {
printToken("MULT", yytext);
return T_MULT;
}
"/" {
printToken("DIV", yytext);
return T_DIV;
}
"-" {
printToken("SUB", yytext);
return T_SUB;
}
"and" {
printToken("AND", yytext);
return T_AND;
}
"or" {
printToken("OR", yytext);
return T_OR;
}
"not" {
printToken("NOT", yytext);
return T_NOT;
}
"<" {
printToken("LT", yytext);
return T_LT;
}
">" {
printToken("GT", yytext);
return T_GT;
}
"<=" {
printToken("LE", yytext);
return T_LE;
}
">=" {
printToken("GE", yytext);
return T_GE;
}
"=" {
printToken("EQ", yytext);
return T_EQ;
}
"/=" {
printToken("NE", yytext);
return T_NE;
}
"t" {
printToken("T", yytext);
return T_T;
}
"nil" {
printToken("NIL", yytext);
return T_NIL;
}
{IDENT} {
yylval.text = strdup(yytext);
printToken("IDENT", yytext);
return T_IDENT;
}
{INTCONST} {
printToken("INTCONST", yytext);
return T_INTCONST;
}
{STRCONST} {
printToken("STRCONST", yytext);
return T_STRCONST;
}
......@@ -184,7 +157,6 @@ COMMENT ";".*
{WSPACE} { }
. {
printToken("UNKNOWN", yytext);
return T_UNKNOWN;
}
%%
\ No newline at end of file
This diff is collapsed.