aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c26
-rw-r--r--pc.y5
2 files changed, 10 insertions, 21 deletions
diff --git a/main.c b/main.c
index 6c601ff..394e3bc 100644
--- a/main.c
+++ b/main.c
@@ -139,27 +139,19 @@ ptree *t;
{
int r, l;
- if (t->r && t->r->type == LIST)
- r = count_args(t->r);
- else if (t->r && t->r->type == ID)
- r = 1;
- else {
- char buf[100];
- snprintf(buf, 100, "COUNT ARGS1: %d\n",(t->r));
- yyerror(buf);
- }
+ if (!t)
+ return 0;
- if (t->l && t->l->type == LIST)
+ if (t->type == LIST){
+ r = count_args(t->r);
l = count_args(t->l);
- else if (t->l && t->l->type == ID)
- l = 1;
- else{
- char buf[100];
- snprintf(buf, 100, "COUNT ARGS2: %d\n", (t->l));
- yyerror(buf);
+ } else if (t->type == ID) {
+ return 1;
+ } else {
+ yyerror("NOT A PARAMETER LIST\n");
}
- return l + r;
+ return r + l;
}
int set_func_types(t, nxt, size)
diff --git a/pc.y b/pc.y
index 8991403..dc7b704 100644
--- a/pc.y
+++ b/pc.y
@@ -178,10 +178,7 @@ sub_prog_head
check_id(cur_scope->prev, $2);
tmp = scope_insert(cur_scope->prev, $2);
- if ($3->type == ID)
- i = 1;
- else
- i = count_args($3);
+ i = count_args($3);
tmp->func_info = malloc(sizeof(struct fi));
assert(tmp->func_info);