aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-05 10:50:02 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-05 10:50:02 -0400
commitd8a7a9b0ed653ec8061896efc0c8e11b5df6b166 (patch)
tree8fe8cb78ee8b0a99a20e5685a0518d62703fb9b5 /main.c
parent30a16a2fdfd527e89a83f49f53cb448aafcb4e9a (diff)
Add counting of function arguments
Diffstat (limited to 'main.c')
-rw-r--r--main.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/main.c b/main.c
index 34acd52..d6cffdd 100644
--- a/main.c
+++ b/main.c
@@ -134,6 +134,34 @@ char* msg;
return 0;
}
+int count_args(t)
+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->l && t->l->type == LIST)
+ 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);
+ }
+
+ return l + r;
+}
+
int main()
{
#ifdef DEBUG_TYPES