aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pc.y6
-rw-r--r--sem_check.c4
-rw-r--r--tree.c3
3 files changed, 12 insertions, 1 deletions
diff --git a/pc.y b/pc.y
index d679c18..ca94f5d 100644
--- a/pc.y
+++ b/pc.y
@@ -402,5 +402,11 @@ factor
{
$$ = mktree(NOT, $2, NULL);
}
+ |ADDOP factor{
+ if ($1 != SUB)
+ yyerror("SUB NOT CORRECT\n");
+ else
+ $$ = mktree(SUB, $2, NULL);
+ }
;
diff --git a/sem_check.c b/sem_check.c
index 773c70a..aa83155 100644
--- a/sem_check.c
+++ b/sem_check.c
@@ -54,7 +54,7 @@ ptree *t;
if (!(t->r && t->l))
yyerror("Missing nodes\n");
- if (t->attr.opval == ADD || t->attr.opval == OR) {
+ if (t->attr.opval == AND || t->attr.opval == OR) {
if(t->l->ret_type == BOOL && t->r->ret_type ==BOOL)
return BOOL;
else {
@@ -162,6 +162,8 @@ ptree *t;
if (t->l->ret_type == 1 && t->r->ret_type == INT)
return 1;
snprintf(buf, 100, "Incorrect types HERE...\n");
+ case SUB:
+ return t->l->ret_type;
break;
default:
return -200;
diff --git a/tree.c b/tree.c
index bb025f5..2afdfa6 100644
--- a/tree.c
+++ b/tree.c
@@ -182,6 +182,9 @@ int spaces;
case DT:
fprintf(stderr, "[DOWN-TO]");
break;
+ case SUB:
+ fprintf(stderr, "[SUB]");
+ break;
default:
fprintf(stderr, "\t%d", t->type);
yyerror("Error in tree_print");