PageRenderTime 67ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/vm/parser/grammar.y

https://github.com/vasco/rubinius
Happy | 5899 lines | 5381 code | 518 blank | 0 comment | 0 complexity | aaf3402f7f095f9d63e9e0e227071d1c MD5 | raw file
Possible License(s): GPL-2.0, BSD-2-Clause, LGPL-2.1, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. /**********************************************************************
  2. parse.y -
  3. $Author: matz $
  4. $Date: 2004/11/29 06:13:51 $
  5. created at: Fri May 28 18:02:42 JST 1993
  6. Copyright (C) 1993-2003 Yukihiro Matsumoto
  7. **********************************************************************/
  8. %{
  9. #define YYDEBUG 1
  10. #define YYERROR_VERBOSE 1
  11. #include <stdio.h>
  12. #include <errno.h>
  13. #include <ctype.h>
  14. #include <string.h>
  15. #include <stdbool.h>
  16. #include "builtin/array.hpp"
  17. #include "parser/grammar_internal.hpp"
  18. #include "parser/grammar_runtime.hpp"
  19. #include "parser/local_state.hpp"
  20. #include "objectmemory.hpp"
  21. namespace rubinius {
  22. namespace parser {
  23. #undef VALUE
  24. #ifndef isnumber
  25. #define isnumber isdigit
  26. #endif
  27. /* Defined at least in mach/boolean.h on OS X. */
  28. #ifdef TRUE
  29. #undef TRUE
  30. #endif
  31. #ifdef FALSE
  32. #undef FALSE
  33. #endif
  34. #define TRUE true
  35. #define FALSE false
  36. #define ISALPHA isalpha
  37. #define ISSPACE isspace
  38. #define ISALNUM(x) (isalpha(x) || isnumber(x))
  39. #define ISDIGIT isdigit
  40. #define ISXDIGIT isxdigit
  41. #define ISUPPER isupper
  42. #define ismbchar(c) (0)
  43. #define mbclen(c) (1)
  44. #define ID2SYM(i) (Object*)i
  45. #define string_new(ptr, len) blk2bstr(ptr, len)
  46. #define string_new2(ptr) cstr2bstr(ptr)
  47. intptr_t syd_sourceline;
  48. static char *syd_sourcefile;
  49. #define ruby_sourceline syd_sourceline
  50. #define ruby_sourcefile syd_sourcefile
  51. static int
  52. syd_yyerror(const char *, rb_parse_state*);
  53. #define yyparse syd_yyparse
  54. #define yylex syd_yylex
  55. #define yyerror(str) syd_yyerror(str, (rb_parse_state*)parse_state)
  56. #define yylval syd_yylval
  57. #define yychar syd_yychar
  58. #define yydebug syd_yydebug
  59. #define YYPARSE_PARAM parse_state
  60. #define YYLEX_PARAM parse_state
  61. #define ID_SCOPE_SHIFT 3
  62. #define ID_SCOPE_MASK 0x07
  63. #define ID_LOCAL 0x01
  64. #define ID_INSTANCE 0x02
  65. #define ID_GLOBAL 0x03
  66. #define ID_ATTRSET 0x04
  67. #define ID_CONST 0x05
  68. #define ID_CLASS 0x06
  69. #define ID_JUNK 0x07
  70. #define ID_INTERNAL ID_JUNK
  71. #define is_notop_id(id) ((id)>tLAST_TOKEN)
  72. #define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
  73. #define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
  74. #define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
  75. #define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
  76. #define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
  77. #define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
  78. #define is_junk_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_JUNK)
  79. #define is_asgn_or_id(id) ((is_notop_id(id)) && \
  80. (((id)&ID_SCOPE_MASK) == ID_GLOBAL || \
  81. ((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
  82. ((id)&ID_SCOPE_MASK) == ID_CLASS))
  83. /* FIXME these went into the ruby_state instead of parse_state
  84. because a ton of other crap depends on it
  85. char *ruby_sourcefile; current source file
  86. int ruby_sourceline; current line no.
  87. */
  88. static int yylex(void*, void *);
  89. #define BITSTACK_PUSH(stack, n) (stack = (stack<<1)|((n)&1))
  90. #define BITSTACK_POP(stack) (stack >>= 1)
  91. #define BITSTACK_LEXPOP(stack) (stack = (stack >> 1) | (stack & 1))
  92. #define BITSTACK_SET_P(stack) (stack&1)
  93. #define COND_PUSH(n) BITSTACK_PUSH(vps->cond_stack, n)
  94. #define COND_POP() BITSTACK_POP(vps->cond_stack)
  95. #define COND_LEXPOP() BITSTACK_LEXPOP(vps->cond_stack)
  96. #define COND_P() BITSTACK_SET_P(vps->cond_stack)
  97. #define CMDARG_PUSH(n) BITSTACK_PUSH(vps->cmdarg_stack, n)
  98. #define CMDARG_POP() BITSTACK_POP(vps->cmdarg_stack)
  99. #define CMDARG_LEXPOP() BITSTACK_LEXPOP(vps->cmdarg_stack)
  100. #define CMDARG_P() BITSTACK_SET_P(vps->cmdarg_stack)
  101. /*
  102. static int class_nest = 0;
  103. static int in_single = 0;
  104. static int in_def = 0;
  105. static int compile_for_eval = 0;
  106. static ID cur_mid = 0;
  107. */
  108. static NODE *cond(NODE*,rb_parse_state*);
  109. static NODE *logop(enum node_type,NODE*,NODE*,rb_parse_state*);
  110. static int cond_negative(NODE**);
  111. static NODE *newline_node(rb_parse_state*,NODE*);
  112. static void fixpos(NODE*,NODE*);
  113. static int value_expr0(NODE*,rb_parse_state*);
  114. static void void_expr0(NODE *);
  115. static void void_stmts(NODE*,rb_parse_state*);
  116. static NODE *remove_begin(NODE*,rb_parse_state*);
  117. #define value_expr(node) value_expr0((node) = \
  118. remove_begin(node, (rb_parse_state*)parse_state), \
  119. (rb_parse_state*)parse_state)
  120. #define void_expr(node) void_expr0((node) = remove_begin(node, (rb_parse_state*)parse_state))
  121. static NODE *block_append(rb_parse_state*,NODE*,NODE*);
  122. static NODE *list_append(rb_parse_state*,NODE*,NODE*);
  123. static NODE *list_concat(NODE*,NODE*);
  124. static NODE *arg_concat(rb_parse_state*,NODE*,NODE*);
  125. static NODE *arg_prepend(rb_parse_state*,NODE*,NODE*);
  126. static NODE *literal_concat(rb_parse_state*,NODE*,NODE*);
  127. static NODE *new_evstr(rb_parse_state*,NODE*);
  128. static NODE *evstr2dstr(rb_parse_state*,NODE*);
  129. static NODE *call_op(NODE*,ID,int,NODE*,rb_parse_state*);
  130. /* static NODE *negate_lit(NODE*); */
  131. static NODE *ret_args(rb_parse_state*,NODE*);
  132. static NODE *arg_blk_pass(NODE*,NODE*);
  133. static NODE *new_call(rb_parse_state*,NODE*,ID,NODE*);
  134. static NODE *new_fcall(rb_parse_state*,ID,NODE*);
  135. static NODE *new_super(rb_parse_state*,NODE*);
  136. static NODE *new_yield(rb_parse_state*,NODE*);
  137. static NODE *syd_gettable(rb_parse_state*,ID);
  138. #define gettable(i) syd_gettable((rb_parse_state*)parse_state, i)
  139. static NODE *assignable(ID,NODE*,rb_parse_state*);
  140. static NODE *aryset(NODE*,NODE*,rb_parse_state*);
  141. static NODE *attrset(NODE*,ID,rb_parse_state*);
  142. static void rb_backref_error(NODE*,rb_parse_state*);
  143. static NODE *node_assign(NODE*,NODE*,rb_parse_state*);
  144. static NODE *match_gen(NODE*,NODE*,rb_parse_state*);
  145. static void syd_local_push(rb_parse_state*, int cnt);
  146. #define local_push(cnt) syd_local_push(vps, cnt)
  147. static void syd_local_pop(rb_parse_state*);
  148. #define local_pop() syd_local_pop(vps)
  149. static intptr_t syd_local_cnt(rb_parse_state*,ID);
  150. #define local_cnt(i) syd_local_cnt(vps, i)
  151. static int syd_local_id(rb_parse_state*,ID);
  152. #define local_id(i) syd_local_id(vps, i)
  153. static ID *syd_local_tbl(rb_parse_state *st);
  154. static ID convert_op(ID id);
  155. static void tokadd(char c, rb_parse_state *parse_state);
  156. static int tokadd_string(int, int, int, quark *, rb_parse_state*);
  157. #define SHOW_PARSER_WARNS 0
  158. static int rb_compile_error(rb_parse_state *st, const char *fmt, ...) {
  159. va_list ar;
  160. char msg[256];
  161. int count;
  162. va_start(ar, fmt);
  163. count = vsnprintf(msg, 256, fmt, ar);
  164. va_end(ar);
  165. syd_yyerror(msg, st);
  166. return count;
  167. }
  168. static int _debug_print(const char *fmt, ...) {
  169. #if SHOW_PARSER_WARNS
  170. va_list ar;
  171. int i;
  172. va_start(ar, fmt);
  173. i = vprintf(fmt, ar);
  174. va_end(ar);
  175. return i;
  176. #else
  177. return 0;
  178. #endif
  179. }
  180. #define rb_warn _debug_print
  181. #define rb_warning _debug_print
  182. static ID rb_intern(const char *name);
  183. static ID rb_id_attrset(ID);
  184. rb_parse_state *alloc_parse_state();
  185. static unsigned long scan_oct(const char *start, int len, int *retlen);
  186. static unsigned long scan_hex(const char *start, int len, int *retlen);
  187. static void reset_block(rb_parse_state *parse_state);
  188. static NODE *extract_block_vars(rb_parse_state *parse_state, NODE* node, var_table vars);
  189. #define ruby_verbose 0
  190. #define RE_OPTION_ONCE 0x80
  191. #define RE_OPTION_IGNORECASE (1L)
  192. #define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
  193. #define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1)
  194. #define RE_OPTION_SINGLELINE (RE_OPTION_MULTILINE<<1)
  195. #define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
  196. #define RE_MAY_IGNORECASE (RE_OPTION_LONGEST<<1)
  197. #define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
  198. #define RE_OPTIMIZE_EXACTN (RE_OPTIMIZE_ANCHOR<<1)
  199. #define RE_OPTIMIZE_NO_BM (RE_OPTIMIZE_EXACTN<<1)
  200. #define RE_OPTIMIZE_BMATCH (RE_OPTIMIZE_NO_BM<<1)
  201. #define NODE_STRTERM NODE_ZARRAY /* nothing to gc */
  202. #define NODE_HEREDOC NODE_ARRAY /* 1, 3 to gc */
  203. #define SIGN_EXTEND(x,n) (((1<<((n)-1))^((x)&~(~0<<(n))))-(1<<((n)-1)))
  204. #define nd_func u1.id
  205. #if SIZEOF_SHORT != 2
  206. #define nd_term(node) SIGN_EXTEND((node)->u2.id, (CHAR_BIT*2))
  207. #else
  208. #define nd_term(node) ((signed short)(node)->u2.id)
  209. #endif
  210. #define nd_paren(node) (char)((node)->u2.id >> (CHAR_BIT*2))
  211. #define nd_nest u3.id
  212. /* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
  213. for instance). This is too low for Ruby to parse some files, such as
  214. date/format.rb, therefore bump the value up to at least Bison's default. */
  215. #ifdef OLD_YACC
  216. #ifndef YYMAXDEPTH
  217. #define YYMAXDEPTH 10000
  218. #endif
  219. #endif
  220. #define vps ((rb_parse_state*)parse_state)
  221. %}
  222. %pure-parser
  223. %union {
  224. NODE *node;
  225. ID id;
  226. int num;
  227. var_table vars;
  228. }
  229. %token kCLASS
  230. kMODULE
  231. kDEF
  232. kUNDEF
  233. kBEGIN
  234. kRESCUE
  235. kENSURE
  236. kEND
  237. kIF
  238. kUNLESS
  239. kTHEN
  240. kELSIF
  241. kELSE
  242. kCASE
  243. kWHEN
  244. kWHILE
  245. kUNTIL
  246. kFOR
  247. kBREAK
  248. kNEXT
  249. kREDO
  250. kRETRY
  251. kIN
  252. kDO
  253. kDO_COND
  254. kDO_BLOCK
  255. kRETURN
  256. kYIELD
  257. kSUPER
  258. kSELF
  259. kNIL
  260. kTRUE
  261. kFALSE
  262. kAND
  263. kOR
  264. kNOT
  265. kIF_MOD
  266. kUNLESS_MOD
  267. kWHILE_MOD
  268. kUNTIL_MOD
  269. kRESCUE_MOD
  270. kALIAS
  271. kDEFINED
  272. klBEGIN
  273. klEND
  274. k__LINE__
  275. k__FILE__
  276. k__END__
  277. %token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tXSTRING_BEG
  278. %token <node> tINTEGER tFLOAT tSTRING_CONTENT tEND_DATA
  279. %token <node> tNTH_REF tBACK_REF
  280. %token <num> tREGEXP_END
  281. %type <node> singleton strings string string1 xstring regexp
  282. %type <node> string_contents xstring_contents string_content
  283. %type <node> words qwords word_list qword_list word
  284. %type <node> literal numeric dsym cpath
  285. %type <node> bodystmt compstmt opt_end_data stmts stmt expr arg primary command command_call method_call
  286. %type <node> expr_value arg_value primary_value
  287. %type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
  288. %type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args
  289. %type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
  290. %type <node> mrhs superclass block_call block_command
  291. %type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
  292. %type <node> assoc_list assocs assoc undef_list backref string_dvar
  293. %type <node> block_var opt_block_var brace_block cmd_brace_block do_block lhs none fitem
  294. %type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
  295. %type <id> fsym variable sym symbol operation operation2 operation3
  296. %type <id> cname fname op f_rest_arg
  297. %type <num> f_norm_arg f_arg
  298. %token tUPLUS /* unary+ */
  299. %token tUMINUS /* unary- */
  300. %token tUBS /* unary\ */
  301. %token tPOW /* ** */
  302. %token tCMP /* <=> */
  303. %token tEQ /* == */
  304. %token tEQQ /* === */
  305. %token tNEQ /* != */
  306. %token tGEQ /* >= */
  307. %token tLEQ /* <= */
  308. %token tANDOP tOROP /* && and || */
  309. %token tMATCH tNMATCH /* =~ and !~ */
  310. %token tDOT2 tDOT3 /* .. and ... */
  311. %token tAREF tASET /* [] and []= */
  312. %token tLSHFT tRSHFT /* << and >> */
  313. %token tCOLON2 /* :: */
  314. %token tCOLON3 /* :: at EXPR_BEG */
  315. %token <id> tOP_ASGN /* +=, -= etc. */
  316. %token tASSOC /* => */
  317. %token tLPAREN /* ( */
  318. %token tLPAREN_ARG /* ( */
  319. %token tRPAREN /* ) */
  320. %token tLBRACK /* [ */
  321. %token tLBRACE /* { */
  322. %token tLBRACE_ARG /* { */
  323. %token tSTAR /* * */
  324. %token tAMPER /* & */
  325. %token tSYMBEG tSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG
  326. %token tSTRING_DBEG tSTRING_DVAR tSTRING_END
  327. /*
  328. * precedence table
  329. */
  330. %nonassoc tLOWEST
  331. %nonassoc tLBRACE_ARG
  332. %nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
  333. %left kOR kAND
  334. %right kNOT
  335. %nonassoc kDEFINED
  336. %right '=' tOP_ASGN
  337. %left kRESCUE_MOD
  338. %right '?' ':'
  339. %nonassoc tDOT2 tDOT3
  340. %left tOROP
  341. %left tANDOP
  342. %nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
  343. %left '>' tGEQ '<' tLEQ
  344. %left '|' '^'
  345. %left '&'
  346. %left tLSHFT tRSHFT
  347. %left '+' '-'
  348. %left '*' '/' '%'
  349. %right tUMINUS_NUM tUMINUS
  350. %right tPOW
  351. %right '!' '~' tUPLUS
  352. %token tLAST_TOKEN
  353. %%
  354. program : {
  355. vps->lex_state = EXPR_BEG;
  356. vps->variables = new LocalState(0);
  357. class_nest = 0;
  358. }
  359. compstmt opt_end_data
  360. {
  361. if ($2 && !compile_for_eval) {
  362. /* last expression should not be void */
  363. if (nd_type($2) != NODE_BLOCK) void_expr($2);
  364. else {
  365. NODE *node = $2;
  366. while (node->nd_next) {
  367. node = node->nd_next;
  368. }
  369. void_expr(node->nd_head);
  370. }
  371. }
  372. vps->top = block_append(vps, vps->top, $2);
  373. if ($3)
  374. vps->top = block_append(vps, $3, vps->top);
  375. class_nest = 0;
  376. }
  377. ;
  378. bodystmt : compstmt
  379. opt_rescue
  380. opt_else
  381. opt_ensure
  382. {
  383. $$ = $1;
  384. if ($2) {
  385. $$ = NEW_RESCUE($1, $2, $3);
  386. }
  387. else if ($3) {
  388. rb_warn("else without rescue is useless");
  389. $$ = block_append(vps, $$, $3);
  390. }
  391. if ($4) {
  392. $$ = NEW_ENSURE($$, $4);
  393. }
  394. fixpos($$, $1);
  395. }
  396. ;
  397. compstmt : stmts opt_terms
  398. {
  399. void_stmts($1, vps);
  400. $$ = $1;
  401. }
  402. ;
  403. opt_end_data : none
  404. | k__END__ tEND_DATA
  405. {
  406. $$ = $2;
  407. }
  408. stmts : none
  409. | stmt
  410. {
  411. $$ = newline_node(vps, $1);
  412. }
  413. | stmts terms stmt
  414. {
  415. $$ = block_append(vps, $1, newline_node(vps, $3));
  416. }
  417. | error stmt
  418. {
  419. $$ = remove_begin($2, vps);
  420. }
  421. ;
  422. stmt : kALIAS fitem {vps->lex_state = EXPR_FNAME;} fitem
  423. {
  424. $$ = NEW_ALIAS($2, $4);
  425. }
  426. | kALIAS tGVAR tGVAR
  427. {
  428. $$ = NEW_VALIAS($2, $3);
  429. }
  430. | kALIAS tGVAR tBACK_REF
  431. {
  432. char buf[3];
  433. snprintf(buf, sizeof(buf), "$%c", (char)$3->nd_nth);
  434. $$ = NEW_VALIAS($2, rb_intern(buf));
  435. }
  436. | kALIAS tGVAR tNTH_REF
  437. {
  438. yyerror("can't make alias for the number variables");
  439. $$ = 0;
  440. }
  441. | kUNDEF undef_list
  442. {
  443. $$ = $2;
  444. }
  445. | stmt kIF_MOD expr_value
  446. {
  447. $$ = NEW_IF(cond($3, vps), remove_begin($1, vps), 0);
  448. fixpos($$, $3);
  449. if (cond_negative(&$$->nd_cond)) {
  450. $$->nd_else = $$->nd_body;
  451. $$->nd_body = 0;
  452. }
  453. }
  454. | stmt kUNLESS_MOD expr_value
  455. {
  456. $$ = NEW_UNLESS(cond($3, vps), remove_begin($1, vps), 0);
  457. fixpos($$, $3);
  458. if (cond_negative(&$$->nd_cond)) {
  459. $$->nd_body = $$->nd_else;
  460. $$->nd_else = 0;
  461. }
  462. }
  463. | stmt kWHILE_MOD expr_value
  464. {
  465. if ($1 && nd_type($1) == NODE_BEGIN) {
  466. $$ = NEW_WHILE(cond($3, vps), $1->nd_body, 0);
  467. }
  468. else {
  469. $$ = NEW_WHILE(cond($3, vps), $1, 1);
  470. }
  471. if (cond_negative(&$$->nd_cond)) {
  472. nd_set_type($$, NODE_UNTIL);
  473. }
  474. }
  475. | stmt kUNTIL_MOD expr_value
  476. {
  477. if ($1 && nd_type($1) == NODE_BEGIN) {
  478. $$ = NEW_UNTIL(cond($3, vps), $1->nd_body, 0);
  479. }
  480. else {
  481. $$ = NEW_UNTIL(cond($3, vps), $1, 1);
  482. }
  483. if (cond_negative(&$$->nd_cond)) {
  484. nd_set_type($$, NODE_WHILE);
  485. }
  486. }
  487. | stmt kRESCUE_MOD stmt
  488. {
  489. NODE *resq = NEW_RESBODY(0, remove_begin($3, vps), 0);
  490. $$ = NEW_RESCUE(remove_begin($1, vps), resq, 0);
  491. }
  492. | klBEGIN
  493. {
  494. if (in_def || in_single) {
  495. yyerror("BEGIN in method");
  496. }
  497. local_push(0);
  498. }
  499. '{' compstmt '}'
  500. {
  501. /*
  502. ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
  503. NEW_PREEXE($4));
  504. */
  505. local_pop();
  506. $$ = 0;
  507. }
  508. | klEND '{' compstmt '}'
  509. {
  510. if (in_def || in_single) {
  511. rb_warn("END in method; use at_exit");
  512. }
  513. $$ = NEW_ITER(0, NEW_POSTEXE(), $3);
  514. }
  515. | lhs '=' command_call
  516. {
  517. $$ = node_assign($1, $3, vps);
  518. }
  519. | mlhs '=' command_call
  520. {
  521. value_expr($3);
  522. $1->nd_value = ($1->nd_head) ? NEW_TO_ARY($3) : NEW_ARRAY($3);
  523. $$ = $1;
  524. }
  525. | var_lhs tOP_ASGN command_call
  526. {
  527. value_expr($3);
  528. if ($1) {
  529. ID vid = $1->nd_vid;
  530. if ($2 == tOROP) {
  531. $1->nd_value = $3;
  532. $$ = NEW_OP_ASGN_OR(gettable(vid), $1);
  533. if (is_asgn_or_id(vid)) {
  534. $$->nd_aid = vid;
  535. }
  536. }
  537. else if ($2 == tANDOP) {
  538. $1->nd_value = $3;
  539. $$ = NEW_OP_ASGN_AND(gettable(vid), $1);
  540. }
  541. else {
  542. $$ = $1;
  543. $$->nd_value = call_op(gettable(vid),$2,1,$3, vps);
  544. }
  545. }
  546. else {
  547. $$ = 0;
  548. }
  549. }
  550. | primary_value '[' aref_args ']' tOP_ASGN command_call
  551. {
  552. NODE *args;
  553. value_expr($6);
  554. if (!$3) $3 = NEW_ZARRAY();
  555. args = arg_concat(vps, $6, $3);
  556. if ($5 == tOROP) {
  557. $5 = 0;
  558. }
  559. else if ($5 == tANDOP) {
  560. $5 = 1;
  561. }
  562. $$ = NEW_OP_ASGN1($1, $5, args);
  563. fixpos($$, $1);
  564. }
  565. | primary_value '.' tIDENTIFIER tOP_ASGN command_call
  566. {
  567. value_expr($5);
  568. if ($4 == tOROP) {
  569. $4 = 0;
  570. }
  571. else if ($4 == tANDOP) {
  572. $4 = 1;
  573. }
  574. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  575. fixpos($$, $1);
  576. }
  577. | primary_value '.' tCONSTANT tOP_ASGN command_call
  578. {
  579. value_expr($5);
  580. if ($4 == tOROP) {
  581. $4 = 0;
  582. }
  583. else if ($4 == tANDOP) {
  584. $4 = 1;
  585. }
  586. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  587. fixpos($$, $1);
  588. }
  589. | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
  590. {
  591. value_expr($5);
  592. if ($4 == tOROP) {
  593. $4 = 0;
  594. }
  595. else if ($4 == tANDOP) {
  596. $4 = 1;
  597. }
  598. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  599. fixpos($$, $1);
  600. }
  601. | backref tOP_ASGN command_call
  602. {
  603. rb_backref_error($1, vps);
  604. $$ = 0;
  605. }
  606. | lhs '=' mrhs
  607. {
  608. $$ = node_assign($1, NEW_SVALUE($3), vps);
  609. }
  610. | mlhs '=' arg_value
  611. {
  612. $1->nd_value = ($1->nd_head) ? NEW_TO_ARY($3) : NEW_ARRAY($3);
  613. $$ = $1;
  614. }
  615. | mlhs '=' mrhs
  616. {
  617. $1->nd_value = $3;
  618. $$ = $1;
  619. }
  620. | expr
  621. ;
  622. expr : command_call
  623. | expr kAND expr
  624. {
  625. $$ = logop(NODE_AND, $1, $3, vps);
  626. }
  627. | expr kOR expr
  628. {
  629. $$ = logop(NODE_OR, $1, $3, vps);
  630. }
  631. | kNOT expr
  632. {
  633. $$ = NEW_NOT(cond($2, vps));
  634. }
  635. | '!' command_call
  636. {
  637. $$ = NEW_NOT(cond($2, vps));
  638. }
  639. | arg
  640. ;
  641. expr_value : expr
  642. {
  643. value_expr($$);
  644. $$ = $1;
  645. }
  646. ;
  647. command_call : command
  648. | block_command
  649. | kRETURN call_args
  650. {
  651. $$ = NEW_RETURN(ret_args(vps, $2));
  652. }
  653. | kBREAK call_args
  654. {
  655. $$ = NEW_BREAK(ret_args(vps, $2));
  656. }
  657. | kNEXT call_args
  658. {
  659. $$ = NEW_NEXT(ret_args(vps, $2));
  660. }
  661. ;
  662. block_command : block_call
  663. | block_call '.' operation2 command_args
  664. {
  665. $$ = new_call(vps, $1, $3, $4);
  666. }
  667. | block_call tCOLON2 operation2 command_args
  668. {
  669. $$ = new_call(vps, $1, $3, $4);
  670. }
  671. ;
  672. cmd_brace_block : tLBRACE_ARG
  673. {
  674. $<num>1 = ruby_sourceline;
  675. reset_block(vps);
  676. }
  677. opt_block_var { $<vars>$ = vps->variables->block_vars; }
  678. compstmt
  679. '}'
  680. {
  681. $$ = NEW_ITER($3, 0, extract_block_vars(vps, $5, $<vars>4));
  682. nd_set_line($$, $<num>1);
  683. }
  684. ;
  685. command : operation command_args %prec tLOWEST
  686. {
  687. $$ = new_fcall(vps, $1, $2);
  688. fixpos($$, $2);
  689. }
  690. | operation command_args cmd_brace_block
  691. {
  692. $$ = new_fcall(vps, $1, $2);
  693. if ($3) {
  694. if (nd_type($$) == NODE_BLOCK_PASS) {
  695. rb_compile_error(vps, "both block arg and actual block given");
  696. }
  697. $3->nd_iter = $$;
  698. $$ = $3;
  699. }
  700. fixpos($$, $2);
  701. }
  702. | primary_value '.' operation2 command_args %prec tLOWEST
  703. {
  704. $$ = new_call(vps, $1, $3, $4);
  705. fixpos($$, $1);
  706. }
  707. | primary_value '.' operation2 command_args cmd_brace_block
  708. {
  709. $$ = new_call(vps, $1, $3, $4);
  710. if ($5) {
  711. if (nd_type($$) == NODE_BLOCK_PASS) {
  712. rb_compile_error(vps, "both block arg and actual block given");
  713. }
  714. $5->nd_iter = $$;
  715. $$ = $5;
  716. }
  717. fixpos($$, $1);
  718. }
  719. | primary_value tCOLON2 operation2 command_args %prec tLOWEST
  720. {
  721. $$ = new_call(vps, $1, $3, $4);
  722. fixpos($$, $1);
  723. }
  724. | primary_value tCOLON2 operation2 command_args cmd_brace_block
  725. {
  726. $$ = new_call(vps, $1, $3, $4);
  727. if ($5) {
  728. if (nd_type($$) == NODE_BLOCK_PASS) {
  729. rb_compile_error(vps, "both block arg and actual block given");
  730. }
  731. $5->nd_iter = $$;
  732. $$ = $5;
  733. }
  734. fixpos($$, $1);
  735. }
  736. | kSUPER command_args
  737. {
  738. $$ = new_super(vps, $2);
  739. fixpos($$, $2);
  740. }
  741. | kYIELD command_args
  742. {
  743. $$ = new_yield(vps, $2);
  744. fixpos($$, $2);
  745. }
  746. ;
  747. mlhs : mlhs_basic
  748. | tLPAREN mlhs_entry ')'
  749. {
  750. $$ = $2;
  751. }
  752. ;
  753. mlhs_entry : mlhs_basic
  754. | tLPAREN mlhs_entry ')'
  755. {
  756. $$ = NEW_MASGN(NEW_LIST($2), 0);
  757. }
  758. ;
  759. mlhs_basic : mlhs_head
  760. {
  761. $$ = NEW_MASGN($1, 0);
  762. }
  763. | mlhs_head mlhs_item
  764. {
  765. $$ = NEW_MASGN(list_append(vps, $1,$2), 0);
  766. }
  767. | mlhs_head tSTAR mlhs_node
  768. {
  769. $$ = NEW_MASGN($1, $3);
  770. }
  771. | mlhs_head tSTAR
  772. {
  773. $$ = NEW_MASGN($1, -1);
  774. }
  775. | tSTAR mlhs_node
  776. {
  777. $$ = NEW_MASGN(0, $2);
  778. }
  779. | tSTAR
  780. {
  781. $$ = NEW_MASGN(0, -1);
  782. }
  783. ;
  784. mlhs_item : mlhs_node
  785. | tLPAREN mlhs_entry ')'
  786. {
  787. $$ = $2;
  788. }
  789. ;
  790. mlhs_head : mlhs_item ','
  791. {
  792. $$ = NEW_LIST($1);
  793. }
  794. | mlhs_head mlhs_item ','
  795. {
  796. $$ = list_append(vps, $1, $2);
  797. }
  798. ;
  799. mlhs_node : variable
  800. {
  801. $$ = assignable($1, 0, vps);
  802. }
  803. | primary_value '[' aref_args ']'
  804. {
  805. $$ = aryset($1, $3, vps);
  806. }
  807. | primary_value '.' tIDENTIFIER
  808. {
  809. $$ = attrset($1, $3, vps);
  810. }
  811. | primary_value tCOLON2 tIDENTIFIER
  812. {
  813. $$ = attrset($1, $3, vps);
  814. }
  815. | primary_value '.' tCONSTANT
  816. {
  817. $$ = attrset($1, $3, vps);
  818. }
  819. | primary_value tCOLON2 tCONSTANT
  820. {
  821. if (in_def || in_single)
  822. yyerror("dynamic constant assignment");
  823. $$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
  824. }
  825. | tCOLON3 tCONSTANT
  826. {
  827. if (in_def || in_single)
  828. yyerror("dynamic constant assignment");
  829. $$ = NEW_CDECL(0, 0, NEW_COLON3($2));
  830. }
  831. | backref
  832. {
  833. rb_backref_error($1, vps);
  834. $$ = 0;
  835. }
  836. ;
  837. lhs : variable
  838. {
  839. $$ = assignable($1, 0, vps);
  840. }
  841. | primary_value '[' aref_args ']'
  842. {
  843. $$ = aryset($1, $3, vps);
  844. }
  845. | primary_value '.' tIDENTIFIER
  846. {
  847. $$ = attrset($1, $3, vps);
  848. }
  849. | primary_value tCOLON2 tIDENTIFIER
  850. {
  851. $$ = attrset($1, $3, vps);
  852. }
  853. | primary_value '.' tCONSTANT
  854. {
  855. $$ = attrset($1, $3, vps);
  856. }
  857. | primary_value tCOLON2 tCONSTANT
  858. {
  859. if (in_def || in_single)
  860. yyerror("dynamic constant assignment");
  861. $$ = NEW_CDECL(0, 0, NEW_COLON2($1, $3));
  862. }
  863. | tCOLON3 tCONSTANT
  864. {
  865. if (in_def || in_single)
  866. yyerror("dynamic constant assignment");
  867. $$ = NEW_CDECL(0, 0, NEW_COLON3($2));
  868. }
  869. | backref
  870. {
  871. rb_backref_error($1, vps);
  872. $$ = 0;
  873. }
  874. ;
  875. cname : tIDENTIFIER
  876. {
  877. yyerror("class/module name must be CONSTANT");
  878. }
  879. | tCONSTANT
  880. ;
  881. cpath : tCOLON3 cname
  882. {
  883. $$ = NEW_COLON3($2);
  884. }
  885. | cname
  886. {
  887. $$ = NEW_COLON2(0, $$);
  888. }
  889. | primary_value tCOLON2 cname
  890. {
  891. $$ = NEW_COLON2($1, $3);
  892. }
  893. ;
  894. fname : tIDENTIFIER
  895. | tCONSTANT
  896. | tFID
  897. | op
  898. {
  899. vps->lex_state = EXPR_END;
  900. $$ = convert_op($1);
  901. }
  902. | reswords
  903. {
  904. vps->lex_state = EXPR_END;
  905. $$ = $<id>1;
  906. }
  907. ;
  908. fsym : fname
  909. | symbol
  910. ;
  911. fitem : fsym
  912. {
  913. $$ = NEW_LIT(ID2SYM($1));
  914. }
  915. | dsym
  916. ;
  917. undef_list : fitem
  918. {
  919. $$ = NEW_UNDEF($1);
  920. }
  921. | undef_list ',' {vps->lex_state = EXPR_FNAME;} fitem
  922. {
  923. $$ = block_append(vps, $1, NEW_UNDEF($4));
  924. }
  925. ;
  926. op : '|' { $$ = '|'; }
  927. | '^' { $$ = '^'; }
  928. | '&' { $$ = '&'; }
  929. | tCMP { $$ = tCMP; }
  930. | tEQ { $$ = tEQ; }
  931. | tEQQ { $$ = tEQQ; }
  932. | tMATCH { $$ = tMATCH; }
  933. | '>' { $$ = '>'; }
  934. | tGEQ { $$ = tGEQ; }
  935. | '<' { $$ = '<'; }
  936. | tLEQ { $$ = tLEQ; }
  937. | tLSHFT { $$ = tLSHFT; }
  938. | tRSHFT { $$ = tRSHFT; }
  939. | '+' { $$ = '+'; }
  940. | '-' { $$ = '-'; }
  941. | '*' { $$ = '*'; }
  942. | tSTAR { $$ = '*'; }
  943. | '/' { $$ = '/'; }
  944. | '%' { $$ = '%'; }
  945. | tPOW { $$ = tPOW; }
  946. | '~' { $$ = '~'; }
  947. | tUPLUS { $$ = tUPLUS; }
  948. | tUMINUS { $$ = tUMINUS; }
  949. | tAREF { $$ = tAREF; }
  950. | tASET { $$ = tASET; }
  951. | '`' { $$ = '`'; }
  952. ;
  953. reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND | k__END__
  954. | kALIAS | kAND | kBEGIN | kBREAK | kCASE | kCLASS | kDEF
  955. | kDEFINED | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE
  956. | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT
  957. | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
  958. | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
  959. | kIF_MOD | kUNLESS_MOD | kWHILE_MOD | kUNTIL_MOD | kRESCUE_MOD
  960. ;
  961. arg : lhs '=' arg
  962. {
  963. $$ = node_assign($1, $3, vps);
  964. }
  965. | lhs '=' arg kRESCUE_MOD arg
  966. {
  967. $$ = node_assign($1, NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0), vps);
  968. }
  969. | var_lhs tOP_ASGN arg
  970. {
  971. value_expr($3);
  972. if ($1) {
  973. ID vid = $1->nd_vid;
  974. if ($2 == tOROP) {
  975. $1->nd_value = $3;
  976. $$ = NEW_OP_ASGN_OR(gettable(vid), $1);
  977. if (is_asgn_or_id(vid)) {
  978. $$->nd_aid = vid;
  979. }
  980. }
  981. else if ($2 == tANDOP) {
  982. $1->nd_value = $3;
  983. $$ = NEW_OP_ASGN_AND(gettable(vid), $1);
  984. }
  985. else {
  986. $$ = $1;
  987. $$->nd_value = call_op(gettable(vid),$2,1,$3, vps);
  988. }
  989. }
  990. else {
  991. $$ = 0;
  992. }
  993. }
  994. | primary_value '[' aref_args ']' tOP_ASGN arg
  995. {
  996. NODE *args;
  997. value_expr($6);
  998. if (!$3) $3 = NEW_ZARRAY();
  999. args = arg_concat(vps, $6, $3);
  1000. if ($5 == tOROP) {
  1001. $5 = 0;
  1002. }
  1003. else if ($5 == tANDOP) {
  1004. $5 = 1;
  1005. }
  1006. $$ = NEW_OP_ASGN1($1, $5, args);
  1007. fixpos($$, $1);
  1008. }
  1009. | primary_value '.' tIDENTIFIER tOP_ASGN arg
  1010. {
  1011. value_expr($5);
  1012. if ($4 == tOROP) {
  1013. $4 = 0;
  1014. }
  1015. else if ($4 == tANDOP) {
  1016. $4 = 1;
  1017. }
  1018. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  1019. fixpos($$, $1);
  1020. }
  1021. | primary_value '.' tCONSTANT tOP_ASGN arg
  1022. {
  1023. value_expr($5);
  1024. if ($4 == tOROP) {
  1025. $4 = 0;
  1026. }
  1027. else if ($4 == tANDOP) {
  1028. $4 = 1;
  1029. }
  1030. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  1031. fixpos($$, $1);
  1032. }
  1033. | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
  1034. {
  1035. value_expr($5);
  1036. if ($4 == tOROP) {
  1037. $4 = 0;
  1038. }
  1039. else if ($4 == tANDOP) {
  1040. $4 = 1;
  1041. }
  1042. $$ = NEW_OP_ASGN2($1, $3, $4, $5);
  1043. fixpos($$, $1);
  1044. }
  1045. | primary_value tCOLON2 tCONSTANT tOP_ASGN arg
  1046. {
  1047. yyerror("constant re-assignment");
  1048. $$ = 0;
  1049. }
  1050. | tCOLON3 tCONSTANT tOP_ASGN arg
  1051. {
  1052. yyerror("constant re-assignment");
  1053. $$ = 0;
  1054. }
  1055. | backref tOP_ASGN arg
  1056. {
  1057. rb_backref_error($1, vps);
  1058. $$ = 0;
  1059. }
  1060. | arg tDOT2 arg
  1061. {
  1062. value_expr($1);
  1063. value_expr($3);
  1064. $$ = NEW_DOT2($1, $3);
  1065. }
  1066. | arg tDOT3 arg
  1067. {
  1068. value_expr($1);
  1069. value_expr($3);
  1070. $$ = NEW_DOT3($1, $3);
  1071. }
  1072. | arg '+' arg
  1073. {
  1074. $$ = call_op($1, '+', 1, $3, vps);
  1075. }
  1076. | arg '-' arg
  1077. {
  1078. $$ = call_op($1, '-', 1, $3, vps);
  1079. }
  1080. | arg '*' arg
  1081. {
  1082. $$ = call_op($1, '*', 1, $3, vps);
  1083. }
  1084. | arg '/' arg
  1085. {
  1086. $$ = call_op($1, '/', 1, $3, vps);
  1087. }
  1088. | arg '%' arg
  1089. {
  1090. $$ = call_op($1, '%', 1, $3, vps);
  1091. }
  1092. | arg tPOW arg
  1093. {
  1094. $$ = call_op($1, tPOW, 1, $3, vps);
  1095. }
  1096. | tUMINUS_NUM tINTEGER tPOW arg
  1097. {
  1098. $$ = call_op(call_op($2, tPOW, 1, $4, vps), tUMINUS, 0, 0, vps);
  1099. }
  1100. | tUMINUS_NUM tFLOAT tPOW arg
  1101. {
  1102. $$ = call_op(call_op($2, tPOW, 1, $4, vps), tUMINUS, 0, 0, vps);
  1103. }
  1104. | tUPLUS arg
  1105. {
  1106. if ($2 && nd_type($2) == NODE_LIT) {
  1107. $$ = $2;
  1108. }
  1109. else {
  1110. $$ = call_op($2, tUPLUS, 0, 0, vps);
  1111. }
  1112. }
  1113. | tUMINUS arg
  1114. {
  1115. $$ = call_op($2, tUMINUS, 0, 0, vps);
  1116. }
  1117. | arg '|' arg
  1118. {
  1119. $$ = call_op($1, '|', 1, $3, vps);
  1120. }
  1121. | arg '^' arg
  1122. {
  1123. $$ = call_op($1, '^', 1, $3, vps);
  1124. }
  1125. | arg '&' arg
  1126. {
  1127. $$ = call_op($1, '&', 1, $3, vps);
  1128. }
  1129. | arg tCMP arg
  1130. {
  1131. $$ = call_op($1, tCMP, 1, $3, vps);
  1132. }
  1133. | arg '>' arg
  1134. {
  1135. $$ = call_op($1, '>', 1, $3, vps);
  1136. }
  1137. | arg tGEQ arg
  1138. {
  1139. $$ = call_op($1, tGEQ, 1, $3, vps);
  1140. }
  1141. | arg '<' arg
  1142. {
  1143. $$ = call_op($1, '<', 1, $3, vps);
  1144. }
  1145. | arg tLEQ arg
  1146. {
  1147. $$ = call_op($1, tLEQ, 1, $3, vps);
  1148. }
  1149. | arg tEQ arg
  1150. {
  1151. $$ = call_op($1, tEQ, 1, $3, vps);
  1152. }
  1153. | arg tEQQ arg
  1154. {
  1155. $$ = call_op($1, tEQQ, 1, $3, vps);
  1156. }
  1157. | arg tNEQ arg
  1158. {
  1159. $$ = NEW_NOT(call_op($1, tEQ, 1, $3, vps));
  1160. }
  1161. | arg tMATCH arg
  1162. {
  1163. $$ = match_gen($1, $3, vps);
  1164. }
  1165. | arg tNMATCH arg
  1166. {
  1167. $$ = NEW_NOT(match_gen($1, $3, vps));
  1168. }
  1169. | '!' arg
  1170. {
  1171. $$ = NEW_NOT(cond($2, vps));
  1172. }
  1173. | '~' arg
  1174. {
  1175. $$ = call_op($2, '~', 0, 0, vps);
  1176. }
  1177. | arg tLSHFT arg
  1178. {
  1179. $$ = call_op($1, tLSHFT, 1, $3, vps);
  1180. }
  1181. | arg tRSHFT arg
  1182. {
  1183. $$ = call_op($1, tRSHFT, 1, $3, vps);
  1184. }
  1185. | arg tANDOP arg
  1186. {
  1187. $$ = logop(NODE_AND, $1, $3, vps);
  1188. }
  1189. | arg tOROP arg
  1190. {
  1191. $$ = logop(NODE_OR, $1, $3, vps);
  1192. }
  1193. | kDEFINED opt_nl {vps->in_defined = 1;} arg
  1194. {
  1195. vps->in_defined = 0;
  1196. $$ = NEW_DEFINED($4);
  1197. }
  1198. | arg '?' {vps->ternary_colon++;} arg ':' arg
  1199. {
  1200. $$ = NEW_IF(cond($1, vps), $4, $6);
  1201. fixpos($$, $1);
  1202. vps->ternary_colon--;
  1203. }
  1204. | primary
  1205. {
  1206. $$ = $1;
  1207. }
  1208. ;
  1209. arg_value : arg
  1210. {
  1211. value_expr($1);
  1212. $$ = $1;
  1213. }
  1214. ;
  1215. aref_args : none
  1216. | command opt_nl
  1217. {
  1218. rb_warn("parenthesize argument(s) for future version");
  1219. $$ = NEW_LIST($1);
  1220. }
  1221. | args trailer
  1222. {
  1223. $$ = $1;
  1224. }
  1225. | args ',' tSTAR arg opt_nl
  1226. {
  1227. value_expr($4);
  1228. $$ = arg_concat(vps, $1, $4);
  1229. }
  1230. | assocs trailer
  1231. {
  1232. $$ = NEW_LIST(NEW_HASH($1));
  1233. }
  1234. | tSTAR arg opt_nl
  1235. {
  1236. value_expr($2);
  1237. $$ = NEW_NEWLINE(NEW_SPLAT($2));
  1238. }
  1239. ;
  1240. paren_args : '(' none ')'
  1241. {
  1242. $$ = $2;
  1243. }
  1244. | '(' call_args opt_nl ')'
  1245. {
  1246. $$ = $2;
  1247. }
  1248. | '(' block_call opt_nl ')'
  1249. {
  1250. rb_warn("parenthesize argument for future version");
  1251. $$ = NEW_LIST($2);
  1252. }
  1253. | '(' args ',' block_call opt_nl ')'
  1254. {
  1255. rb_warn("parenthesize argument for future version");
  1256. $$ = list_append(vps, $2, $4);
  1257. }
  1258. ;
  1259. opt_paren_args : none
  1260. | paren_args
  1261. ;
  1262. call_args : command
  1263. {
  1264. rb_warn("parenthesize argument(s) for future version");
  1265. $$ = NEW_LIST($1);
  1266. }
  1267. | args opt_block_arg
  1268. {
  1269. $$ = arg_blk_pass($1, $2);
  1270. }
  1271. | args ',' tSTAR arg_value opt_block_arg
  1272. {
  1273. $$ = arg_concat(vps, $1, $4);
  1274. $$ = arg_blk_pass($$, $5);
  1275. }
  1276. | assocs opt_block_arg
  1277. {
  1278. $$ = NEW_LIST(NEW_HASH($1));
  1279. $$ = arg_blk_pass($$, $2);
  1280. }
  1281. | assocs ',' tSTAR arg_value opt_block_arg
  1282. {
  1283. $$ = arg_concat(vps, NEW_LIST(NEW_HASH($1)), $4);
  1284. $$ = arg_blk_pass($$, $5);
  1285. }
  1286. | args ',' assocs opt_block_arg
  1287. {
  1288. $$ = list_append(vps, $1, NEW_HASH($3));
  1289. $$ = arg_blk_pass($$, $4);
  1290. }
  1291. | args ',' assocs ',' tSTAR arg opt_block_arg
  1292. {
  1293. value_expr($6);
  1294. $$ = arg_concat(vps, list_append(vps, $1, NEW_HASH($3)), $6);
  1295. $$ = arg_blk_pass($$, $7);
  1296. }
  1297. | tSTAR arg_value opt_block_arg
  1298. {
  1299. $$ = arg_blk_pass(NEW_SPLAT($2), $3);
  1300. }
  1301. | block_arg
  1302. ;
  1303. call_args2 : arg_value ',' args opt_block_arg
  1304. {
  1305. $$ = arg_blk_pass(list_concat(NEW_LIST($1),$3), $4);
  1306. }
  1307. | arg_value ',' block_arg
  1308. {
  1309. $$ = arg_blk_pass($1, $3);
  1310. }
  1311. | arg_value ',' tSTAR arg_value opt_block_arg
  1312. {
  1313. $$ = arg_concat(vps, NEW_LIST($1), $4);
  1314. $$ = arg_blk_pass($$, $5);
  1315. }
  1316. | arg_value ',' args ',' tSTAR arg_value opt_block_arg
  1317. {
  1318. $$ = arg_concat(vps, list_concat(NEW_LIST($1),$3), $6);
  1319. $$ = arg_blk_pass($$, $7);
  1320. }
  1321. | assocs opt_block_arg
  1322. {
  1323. $$ = NEW_LIST(NEW_HASH($1));
  1324. $$ = arg_blk_pass($$, $2);
  1325. }
  1326. | assocs ',' tSTAR arg_value opt_block_arg
  1327. {
  1328. $$ = arg_concat(vps, NEW_LIST(NEW_HASH($1)), $4);
  1329. $$ = arg_blk_pass($$, $5);
  1330. }
  1331. | arg_value ',' assocs opt_block_arg
  1332. {
  1333. $$ = list_append(vps, NEW_LIST($1), NEW_HASH($3));
  1334. $$ = arg_blk_pass($$, $4);
  1335. }
  1336. | arg_value ',' args ',' assocs opt_block_arg
  1337. {
  1338. $$ = list_append(vps, list_concat(NEW_LIST($1),$3), NEW_HASH($5));
  1339. $$ = arg_blk_pass($$, $6);
  1340. }
  1341. | arg_value ',' assocs ',' tSTAR arg_value opt_block_arg
  1342. {
  1343. $$ = arg_concat(vps, list_append(vps, NEW_LIST($1), NEW_HASH($3)), $6);
  1344. $$ = arg_blk_pass($$, $7);
  1345. }
  1346. | arg_value ',' args ',' assocs ',' tSTAR arg_value opt_block_arg
  1347. {
  1348. $$ = arg_concat(vps, list_append(vps,
  1349. list_concat(NEW_LIST($1), $3), NEW_HASH($5)), $8);
  1350. $$ = arg_blk_pass($$, $9);
  1351. }
  1352. | tSTAR arg_value opt_block_arg
  1353. {
  1354. $$ = arg_blk_pass(NEW_SPLAT($2), $3);
  1355. }

Large files files are truncated, but you can click here to view the full file