diff options
author | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-05 10:50:02 -0400 |
---|---|---|
committer | Tucker Evans <tuckerevans24@gmail.com> | 2019-09-05 10:50:02 -0400 |
commit | d8a7a9b0ed653ec8061896efc0c8e11b5df6b166 (patch) | |
tree | 8fe8cb78ee8b0a99a20e5685a0518d62703fb9b5 /main.c | |
parent | 30a16a2fdfd527e89a83f49f53cb448aafcb4e9a (diff) |
Add counting of function arguments
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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 |