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 9cc798ae authored by Hogan's avatar Hogan

//commit before merge

parent 90da42e3
//Anna's.y
%{
#include <stdio.h>
#include <stdlib.h>
......@@ -60,7 +59,7 @@ extern "C"
%type <typeInfo> N_PROGN_OR_USERFUNCTCALL N_ACTUAL_PARAMS N_FUNCT_NAME
%type <typeInfo> N_ARITHLOGIC_EXPR N_IF_EXPR N_LET_EXPR N_ID_EXPR_LIST
%type <typeInfo> N_LAMBDA_EXPR N_ID_LIST N_PRINT_EXPR N_INPUT_EXPR
%type <typeInfo> N_EXPR_LIST N_BIN_OP N_ARITH_OP N_REL_OP N_LOG_OP N_UN_OP
%type <typeInfo> N_EXPR_LIST N_BIN_OP N_ARITH_OP N_REL_OP N_LOG_OP N_UN_OP
/*
* Starting point.
......@@ -205,20 +204,22 @@ N_PARENTHESIZED_EXPR : N_ARITHLOGIC_EXPR //resulting type of whatever rule is
}
;
N_PROGN_OR_USERFUNCTCALL : N_FUNCT_NAME N_ACTUAL_PARAMS
{
{
}
| T_LPAREN N_LAMBDA_EXPR T_RPAREN N_ACTUAL_PARAMS
{
}
| T_LPAREN N_LAMBDA_EXPR T_RPAREN N_ACTUAL_PARAMS
{
}
;
}
;
N_ACTUAL_PARAMS : N_EXPR_LIST
{
}
| /*epsilon*/
{
}
{
$$.type=$1.type;
}
| /*epsilon*/
{
$$.type=NOT_APPLICABLE;
}
N_FUNCT_NAME : T_PROGN
{
......@@ -242,6 +243,8 @@ N_ARITHLOGIC_EXPR : N_UN_OP N_EXPR
| N_BIN_OP N_EXPR N_EXPR
{
//check if operation can be preformed
//if($2==INT && $3==INT)
// $$.type=INT;
}
;
N_IF_EXPR : T_IF N_EXPR N_EXPR N_EXPR
......@@ -279,8 +282,8 @@ N_ID_EXPR_LIST : /* epsilon */
(SYMBOL_TABLE_ENTRY(lexeme,
UNDEFINED));
if (! success)
yyerror("Multiply defined identifier");
$3.type=$4.type;
yyerror("Multiply defined identifier");
$3.type=$4.type;
}
;
......@@ -304,11 +307,12 @@ N_ID_LIST : /* epsilon */
string lexeme = string($2);
printf("___Adding %s to symbol table\n", $2);
bool success = scopeStack.top().addEntry(SYMBOL_TABLE_ENTRY(lexeme,UNDEFINED));
if (! success)
yyerror("Multiply defined identifier");
$2.type=INT_OR_STR_OR_BOOL;
if (! success)
yyerror("Multiply defined identifier");
$2.type=INT_OR_STR_OR_BOOL;
}
;
N_PRINT_EXPR : T_PRINT N_EXPR
{
if($2.type==FUNCTION)
......@@ -462,3 +466,4 @@ int main()
prepareToTerminate();
return 0;
}
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