Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arg_list:
- | arg ',' arg_list {
- int func_arg_list_count(){ int argCount = 0; return argCount+1; }
- %union {
- int val;
- int count;
- char *funcName;
- }
- %token <funcName> ID
- %type <val> exp prop
- %type <count> arg_list
- error: $1 of ‘arg_list’ has no declared type
- | arg ',' arg_list { $$ = $1 + 1; }
- %union {
- int count;
- /* other types */
- }
- %type <count> arg_list non_empty_arg_list
- %%
- arg_list: /* EMPTY */ { $$ = 0; /* An empty list has no arguments */ }
- | non_empty_arg_list { $$ = $1; /* This is the default action. */ }
- non_empty_arg_list:
- arg { $$ = 1; /* Starts with one argument */ }
- | non_empty_arg_list ',' arg { $$ = $1 + 1; /* Now it has one more argument */ }
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement