Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. diff --git a/parse.y b/parse.y
  2. index a6a9a4160b..4470f226a8 100644
  3. --- a/parse.y
  4. +++ b/parse.y
  5. @@ -1004,7 +1004,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
  6. %type <node> words symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
  7. %type <node> literal numeric simple_numeric ssym dsym symbol cpath
  8. %type <node> top_compstmt top_stmts top_stmt begin_block
  9. -%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
  10. +%type <node> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary1 primary2 primary command command_call method_call
  11. %type <node> expr_value expr_value_do arg_value primary_value fcall rel_expr pipeline
  12. %type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
  13. %type <node> args call_args opt_call_args
  14. @@ -1025,7 +1025,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
  15. %type <node> p_expr p_as p_alt p_expr_basic
  16. %type <node> p_args p_args_head p_args_tail p_args_post p_arg
  17. %type <node> p_value p_primitive p_variable p_var_ref p_const
  18. -%type <node> p_kwargs p_kwarg p_kw
  19. +%type <node> p_kwargs p_kwarg p_kw fbody
  20. %type <id> keyword_variable user_variable sym operation operation2 operation3
  21. %type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
  22. %type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
  23. @@ -2564,7 +2564,7 @@ mrhs : args ',' arg_value
  24. }
  25. ;
  26.  
  27. -primary : literal
  28. +primary1 : literal
  29. | strings
  30. | xstring
  31. | regexp
  32. @@ -2574,6 +2574,11 @@ primary : literal
  33. | qsymbols
  34. | var_ref
  35. | backref
  36. + {
  37. + /*%%%*/
  38. + $$ = $1;
  39. + /*% %*/
  40. + }
  41. | tFID
  42. {
  43. /*%%%*/
  44. @@ -2910,32 +2915,6 @@ primary : literal
  45. local_pop(p);
  46. p->in_class = $<num>1 & 1;
  47. }
  48. - | k_def fname
  49. - {
  50. - local_push(p, 0);
  51. - $<id>$ = p->cur_arg;
  52. - p->cur_arg = 0;
  53. - }
  54. - {
  55. - $<num>$ = p->in_def;
  56. - p->in_def = 1;
  57. - }
  58. - f_arglist
  59. - bodystmt
  60. - k_end
  61. - {
  62. - /*%%%*/
  63. - NODE *body = remove_begin($6);
  64. - reduce_nodes(p, &body);
  65. - $$ = NEW_DEFN($2, $5, body, &@$);
  66. - nd_set_line($$->nd_defn, @7.end_pos.lineno);
  67. - set_line_body(body, @1.beg_pos.lineno);
  68. - /*% %*/
  69. - /*% ripper: def!($2, $5, $6) %*/
  70. - local_pop(p);
  71. - p->in_def = $<num>4 & 1;
  72. - p->cur_arg = $<id>3;
  73. - }
  74. | k_def singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
  75. {
  76. $<num>4 = p->in_def;
  77. @@ -2998,7 +2977,56 @@ primary : literal
  78. }
  79. ;
  80.  
  81. -primary_value : primary
  82. +primary2 : k_def fname
  83. + {
  84. + local_push(p, 0);
  85. + $<id>$ = p->cur_arg;
  86. + p->cur_arg = 0;
  87. + }
  88. + {
  89. + $<num>$ = p->in_def;
  90. + p->in_def = 1;
  91. + }
  92. + f_arglist
  93. + fbody
  94. + {
  95. + /*%%%*/
  96. + $$ = NEW_DEFN($2, $5, $6, &@$);
  97. + nd_set_line($$->nd_defn, @6.end_pos.lineno);
  98. + set_line_body($6, @1.beg_pos.lineno);
  99. + /*% %*/
  100. + /*% ripper: def!($2, $5, $6) %*/
  101. + local_pop(p);
  102. + p->in_def = $<num>4 & 1;
  103. + p->cur_arg = $<id>3;
  104. + }
  105. + ;
  106. +
  107. +primary : primary1
  108. + | primary2
  109. + {
  110. + /*%%%*/
  111. + $$ = $1;
  112. + /*% %*/
  113. + }
  114. + ;
  115. +
  116. +fbody : bodystmt
  117. + k_end
  118. + {
  119. + /*%%%*/
  120. + NODE *body = remove_begin($1);
  121. + reduce_nodes(p, &body);
  122. + $$ = body;
  123. + /*% %*/
  124. + }
  125. + | '=' arg
  126. + {
  127. + $$ = $2;
  128. + }
  129. + ;
  130. +
  131. +primary_value : primary1
  132. {
  133. value_expr($1);
  134. $$ = $1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement