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 4b426522 authored by Hogan's avatar Hogan

Started adding value to productions

parent 56c547e2
......@@ -73,35 +73,6 @@ N_START : // epsilon
}
| N_START N_EXPR
{
/*
cout << "EXPR type is: ";
switch ($2.type){
case 1:
cout<<"INT"<<"\n";
break;
case 2:
cout<<"STR"<<"\n";
break;
case 4:
cout<<"BOOL"<<"\n";
break;
case 8:
cout<<"FUNCTION"<<"\n";
break;
case 3:
cout<<"INT_OR_STR"<<"\n";
break;
case 5:
cout<<"INT_OR_BOOL"<<"\n";
break;
case 6:
cout<<"STR_OR_BOOL"<<"\n";
break;
case 7:
cout<<"INT_OR_STR_OR_BOOL"<<"\n";
break;
}
*/
cout << "\nValue of the expression is: ";
cout << $2 <<"\n";
cout << "---- Completed parsing ----\n" << endl;
......@@ -126,6 +97,7 @@ N_EXPR : N_CONST
//resulting type is the type of the identifier
//look up in the symbol table
$$.type = getEntryInAnyScope(lexeme).getTypeInfo().type;
$$.value = getEntryInAnyScope(lexeme).getTypeInfo().value;
}
| T_LPAREN N_PARENTHESIZED_EXPR T_RPAREN
{
......@@ -134,6 +106,7 @@ N_EXPR : N_CONST
$$.type=$2.type;
$$.numParams=$2.numParams;
$$.returnType=$2.returnType;
$$.value = $2.value;
}
;
N_CONST : T_INTCONST
......@@ -143,6 +116,7 @@ N_CONST : T_INTCONST
$$.type=INT;
$$.numParams=NOT_APPLICABLE;
$$.returnType=NOT_APPLICABLE;
}
| T_STRCONST
{
......@@ -170,25 +144,28 @@ N_CONST : T_INTCONST
}
;
N_PARENTHESIZED_EXPR : N_ARITHLOGIC_EXPR
{
{
//check for divison by 0
//resulting type of whatever rule is applied
$$.type=$1.type;
$$.numParams=$1.numParams;
$$.returnType=$1.returnType;
$$.value=$1.value;
}
| N_IF_EXPR
{
$$.type=$1.type;
$$.numParams=$1.numParams;
$$.returnType=$1.returnType;
$$.value=$1.value;
}
| N_LET_EXPR
{
$$.type=$1.type;
$$.numParams=$1.numParams;
$$.returnType=$1.returnType;
$$.value=$1.value;
}
| N_PRINT_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