PageRenderTime 61ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/ext/melbourne/grammar.y

https://github.com/iconoclast/rubinius
Happy | 6000 lines | 5479 code | 521 blank | 0 comment | 0 complexity | 1e9bd5c75927bd499d9b088e8b7bbbe6 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1

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

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