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 587523ef authored by Jonathan Evans's avatar Jonathan Evans

fixed missing assignment for symbol table entry values

parent 3b1035da
......@@ -46,12 +46,12 @@ struct TYPE_INFO
{
TYPE_VALUE value;
// one of the above type codes
int type;
// one of the above type codes
int type;
// numParams and returnType only applicable if type == FUNCTION
// numParams and returnType only applicable if type == FUNCTION
int numParams;
int returnType;
int returnType;
// operatorType is only applicable if production is an operator
int operatorType;
......@@ -136,6 +136,11 @@ struct TYPE_INFO
}
};
#include <iostream>
using std::cout;
using std::endl;
class SYMBOL_TABLE_ENTRY
{
private:
......@@ -155,6 +160,7 @@ public:
SYMBOL_TABLE_ENTRY(const string theName, const TYPE_INFO theType) {
name = theName;
typeInfo.type = theType.type;
typeInfo.value = theType.value;
typeInfo.returnType = theType.returnType;
typeInfo.numParams = theType.numParams;
}
......
......@@ -6,6 +6,9 @@
*/
%{
#include <iostream>
using std::cout;
using std::endl;
int numLines = 1;
void beginScope();
%}
......
......@@ -117,7 +117,7 @@ N_EXPR : N_CONST
$$.type=$1.type;
$$.numParams=NOT_APPLICABLE;
$$.returnType=NOT_APPLICABLE;
$$.value=$1.value;
$$.value=$1.value;
}
| T_IDENT
{
......@@ -131,6 +131,7 @@ N_EXPR : N_CONST
TYPE_INFO entryInfo = getEntryInAnyScope(lexeme).getTypeInfo();
$$.type = entryInfo.type;
$$.value = entryInfo.value;
// cout << lexeme << ": " << getEntryInAnyScope(lexeme).getTypeInfo() << endl;
}
| T_LPAREN N_PARENTHESIZED_EXPR T_RPAREN
{
......@@ -451,6 +452,7 @@ N_LET_EXPR : T_LETSTAR T_LPAREN N_ID_EXPR_LIST T_RPAREN N_EXPR
$$.type=$5.type;
$$.numParams = $5.numParams;
$$.returnType = $5.returnType;
$$.value = $5.value;
}
;
N_ID_EXPR_LIST : /* epsilon */
......@@ -465,7 +467,7 @@ N_ID_EXPR_LIST : /* epsilon */
yyerror("Multiply defined identifier");
}
scopeStack.top().addEntry(SYMBOL_TABLE_ENTRY(lexeme, $4));
scopeStack.top().addEntry(SYMBOL_TABLE_ENTRY(lexeme, $4));
}
;
N_PRINT_EXPR : T_PRINT N_EXPR
......
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