Guest User

Untitled

a guest
Jan 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. N_EXPR_LIST : N_EXPR {printf("b exprs: %d\n", expr_unparsed_count); expr_unparsed_count++;} N_EXPR_LIST
  2. {
  3. expr_unparsed_count--;
  4. printRule("EXPR_LIST", "EXPR EXPR_LIST");
  5. printf("Type: %d compatible: %d\n", $1.type, list_can_be_call);
  6. printf("exprs: %d\n", expr_unparsed_count);
  7.  
  8. if(isFcnCompatible($1)) {
  9. if(expr_unparsed_count == 0 && list_can_be_call) {
  10. if(expr_list_count > $1.numParams) {
  11. yyerror("Too many parameters in function call");
  12. return (1);
  13. }
  14.  
  15. if(expr_list_count < $1.numParams) {
  16. yyerror("Too few parameters in function call");
  17. return (1);
  18. }
  19.  
  20. setType($$, $1.returnType);
  21. }
  22. else {
  23. yyerror("Arg 1 must be of type integer");
  24. return(1);
  25. }
  26. }
  27. else {
  28. expr_list_count++;
  29. list_can_be_call &= isIntCompatible($1);
  30. }
  31. }
  32. | N_EXPR
  33. {
  34. list_can_be_call = true;
  35. expr_list_count = 1;
  36.  
  37. printRule("EXPR_LIST", "EXPR");
  38.  
  39. /* Determine whether we're a valid function call */
  40. list_can_be_call &= isIntCompatible($1);
  41. printf("exprs: %d\n", expr_unparsed_count);
  42. printf("Type: %d compatible: %d\n", $1.type, list_can_be_call);
  43.  
  44. /* Handle the case of 0 args being passed to a function */
  45. if(isFcnCompatible($1)) {
  46. if(expr_unparsed_count == 0) {
  47. if($1.numParams == 0) {
  48. setType($$, $1.returnType);
  49. }
  50. else {
  51. yyerror("Too few parameters in function call");
  52. return (1);
  53. }
  54. }
  55. else {
  56. yyerror("Arg 1 must be of type integer or string");
  57. }
  58. }
  59. else {
  60. setType($$, $1);
  61. }
  62. }
  63. ;
Add Comment
Please, Sign In to add comment