PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/shotgun/lib/grammar.y

https://github.com/reinh/rubinius
Happy | 5899 lines | 5400 code | 499 blank | 0 comment | 0 complexity | 853777cd48b8270b7b994c215120cbe7 MD5 | raw file
Possible License(s): BSD-2-Clause, LGPL-2.1, BSD-3-Clause, GPL-2.0

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

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