aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-05 18:09:37 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-05 18:09:37 -0400
commit1300aa3672d7ae27963465fa6d8d2a6ebe8a71d2 (patch)
tree8d1ada5ceb9a07fcbc105ea5fd0707a6ed3acb12 /main.c
parentc6d13abfc122c15ecc182b1fc5645628e8eb4d18 (diff)
Fix count_args to handle single variable parameters
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 9 insertions, 17 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)