Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. arg_list:
  2. | arg ',' arg_list {
  3. int func_arg_list_count(){ int argCount = 0; return argCount+1; }
  4.  
  5. %union {
  6. int val;
  7. int count;
  8. char *funcName;
  9. }
  10.  
  11. %token <funcName> ID
  12.  
  13. %type <val> exp prop
  14. %type <count> arg_list
  15.  
  16. error: $1 of ‘arg_list’ has no declared type
  17. | arg ',' arg_list { $$ = $1 + 1; }
  18.  
  19. %union {
  20. int count;
  21. /* other types */
  22. }
  23.  
  24. %type <count> arg_list non_empty_arg_list
  25.  
  26. %%
  27.  
  28. arg_list: /* EMPTY */ { $$ = 0; /* An empty list has no arguments */ }
  29. | non_empty_arg_list { $$ = $1; /* This is the default action. */ }
  30.  
  31. non_empty_arg_list:
  32. arg { $$ = 1; /* Starts with one argument */ }
  33. | non_empty_arg_list ',' arg { $$ = $1 + 1; /* Now it has one more argument */ }
  34. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement