Project

General

Profile

0003-implement-a-parser-part-for-basic-keyword-arguments.patch

mame (Yusuke Endoh), 10/18/2011 01:21 AM

View differences:

compile.c
1093 1093
	    iseq->arg_post_len = args->post_args_num;
1094 1094
	}
1095 1095

  
1096
	if (args->kw_args) {
1097
	    rb_notimplement();
1098
	}
1096 1099
	if (args->opt_args) {
1097 1100
	    NODE *node = args->opt_args;
1098 1101
	    LABEL *label;
node.h
154 154
#define NODE_ARGS_AUX    NODE_ARGS_AUX
155 155
    NODE_OPT_ARG,
156 156
#define NODE_OPT_ARG     NODE_OPT_ARG
157
    NODE_KW_ARG,
158
#define NODE_KW_ARG	 NODE_KW_ARG
157 159
    NODE_POSTARG,
158 160
#define NODE_POSTARG     NODE_POSTARG
159 161
    NODE_ARGSCAT,
......
419 421
#define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
420 422
#define NEW_ARGS_AUX(r,b) NEW_NODE(NODE_ARGS_AUX,r,b,0)
421 423
#define NEW_OPT_ARG(i,v) NEW_NODE(NODE_OPT_ARG,i,v,0)
424
#define NEW_KW_ARG(i,v) NEW_NODE(NODE_KW_ARG,i,v,0)
422 425
#define NEW_POSTARG(i,v) NEW_NODE(NODE_POSTARG,i,v,0)
423 426
#define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
424 427
#define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
......
495 498
    ID rest_arg;
496 499
    ID block_arg;
497 500

  
501
    NODE *kw_args;
498 502
    NODE *opt_args;
499 503
};
500 504

  
parse.y
372 372
static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID);
373 373
#define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
374 374

  
375
static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,ID);
376
#define new_args(f,o,r,p,b) new_args_gen(parser, (f),(o),(r),(p),(b))
375
static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,ID);
376
#define new_args(f,o,r,p,k,b) new_args_gen(parser, (f),(o),(r),(p),(k),(b))
377 377

  
378 378
static NODE *negate_lit(NODE*);
379 379
static NODE *ret_args_gen(struct parser_params*,NODE*);
......
501 501
static VALUE ripper_dispatch3(struct parser_params*,ID,VALUE,VALUE,VALUE);
502 502
static VALUE ripper_dispatch4(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE);
503 503
static VALUE ripper_dispatch5(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE);
504
static VALUE ripper_dispatch6(struct parser_params*,ID,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE);
504 505

  
505 506
#define dispatch0(n)            ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
506 507
#define dispatch1(n,a)          ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
......
508 509
#define dispatch3(n,a,b,c)      ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
509 510
#define dispatch4(n,a,b,c,d)    ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
510 511
#define dispatch5(n,a,b,c,d,e)  ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
512
#define dispatch6(n,a,b,c,d,e,f) ripper_dispatch6(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e), (f))
511 513

  
512 514
#define yyparse ripper_yyparse
513 515

  
......
535 537
#define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
536 538
#define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
537 539

  
538
#define params_new(pars, opts, rest, pars2, blk) \
539
        dispatch5(params, (pars), (opts), (rest), (pars2), (blk))
540
#define params_new(pars, opts, rest, pars2, kws, blk) \
541
        dispatch6(params, (pars), (opts), (rest), (pars2), (kws), (blk))
540 542

  
541 543
#define blockvar_new(p,v) dispatch2(block_var, (p), (v))
542 544
#define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
......
697 699
%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
698 700
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
699 701
%type <node> block_param opt_block_param block_param_def f_opt
702
%type <node> f_kwarg f_kw f_block_kwarg f_block_kw
700 703
%type <node> bv_decls opt_bv_decl bvar
701 704
%type <node> lambda f_larglist lambda_body
702 705
%type <node> brace_block cmd_brace_block do_block lhs none fitem
......
2900 2903
				    0),
2901 2904
				node_assign($2, NEW_DVAR(id)));
2902 2905

  
2903
			    args = new_args(m, 0, id, 0, 0);
2906
			    args = new_args(m, 0, id, 0, 0, 0);
2904 2907
			}
2905 2908
			else {
2906 2909
			    if (nd_type($2) == NODE_LASGN ||
......
2909 2912
				$2->nd_value = NEW_DVAR(id);
2910 2913
				m->nd_plen = 1;
2911 2914
				m->nd_next = $2;
2912
				args = new_args(m, 0, 0, 0, 0);
2915
				args = new_args(m, 0, 0, 0, 0, 0);
2913 2916
			    }
2914 2917
			    else {
2915 2918
				m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
2916
				args = new_args(m, 0, id, 0, 0);
2919
				args = new_args(m, 0, id, 0, 0, 0);
2917 2920
			    }
2918 2921
			}
2919 2922
			scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
......
3317 3320
		    }
3318 3321
		;
3319 3322

  
3320
block_param	: f_arg ',' f_block_optarg ',' f_rest_arg opt_f_block_arg
3323
block_param	: f_arg ',' f_block_optarg ',' f_rest_arg ',' f_block_kwarg opt_f_block_arg
3321 3324
		    {
3322 3325
		    /*%%%*/
3323
			$$ = new_args($1, $3, $5, 0, $6);
3326
			$$ = new_args($1, $3, $5, 0, $7, $8);
3324 3327
		    /*%
3325
			$$ = params_new($1, $3, $5, Qnil, escape_Qundef($6));
3328
			$$ = params_new($1, $3, $5, Qnil, $7, escape_Qundef($8));
3329
		    %*/
3330
		    }
3331
		| f_arg ',' f_block_optarg ',' f_rest_arg opt_f_block_arg
3332
		    {
3333
		    /*%%%*/
3334
			$$ = new_args($1, $3, $5, 0, 0, $6);
3335
		    /*%
3336
			$$ = params_new($1, $3, $5, Qnil, Qnil, escape_Qundef($6));
3337
		    %*/
3338
		    }
3339
		| f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3340
		    {
3341
		    /*%%%*/
3342
			$$ = new_args($1, $3, $5, $7, $9, $10);
3343
		    /*%
3344
			$$ = params_new($1, $3, $5, $7, $9, escape_Qundef($10));
3326 3345
		    %*/
3327 3346
		    }
3328 3347
		| f_arg ',' f_block_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
3329 3348
		    {
3330 3349
		    /*%%%*/
3331
			$$ = new_args($1, $3, $5, $7, $8);
3350
			$$ = new_args($1, $3, $5, $7, 0, $8);
3351
		    /*%
3352
			$$ = params_new($1, $3, $5, $7, Qnil, escape_Qundef($8));
3353
		    %*/
3354
		    }
3355
		| f_arg ',' f_block_optarg ',' f_block_kwarg opt_f_block_arg
3356
		    {
3357
		    /*%%%*/
3358
			$$ = new_args($1, $3, 0, 0, $5, $6);
3332 3359
		    /*%
3333
			$$ = params_new($1, $3, $5, $7, escape_Qundef($8));
3360
			$$ = params_new($1, $3, Qnil, Qnil, $5, escape_Qundef($6));
3334 3361
		    %*/
3335 3362
		    }
3336 3363
		| f_arg ',' f_block_optarg opt_f_block_arg
3337 3364
		    {
3338 3365
		    /*%%%*/
3339
			$$ = new_args($1, $3, 0, 0, $4);
3366
			$$ = new_args($1, $3, 0, 0, 0, $4);
3367
		    /*%
3368
			$$ = params_new($1, $3, Qnil, Qnil, Qnil, escape_Qundef($4));
3369
		    %*/
3370
		    }
3371
		| f_arg ',' f_block_optarg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3372
		    {
3373
		    /*%%%*/
3374
			$$ = new_args($1, $3, 0, $5, $7, $8);
3340 3375
		    /*%
3341
			$$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4));
3376
			$$ = params_new($1, $3, Qnil, $5, $7, escape_Qundef($8));
3342 3377
		    %*/
3343 3378
		    }
3344 3379
		| f_arg ',' f_block_optarg ',' f_arg opt_f_block_arg
3345 3380
		    {
3346 3381
		    /*%%%*/
3347
			$$ = new_args($1, $3, 0, $5, $6);
3382
			$$ = new_args($1, $3, 0, $5, 0, $6);
3348 3383
		    /*%
3349
			$$ = params_new($1, $3, Qnil, $5, escape_Qundef($6));
3384
			$$ = params_new($1, $3, Qnil, $5, Qnil, escape_Qundef($6));
3385
		    %*/
3386
		    }
3387
                | f_arg ',' f_rest_arg ',' f_block_kwarg opt_f_block_arg
3388
		    {
3389
		    /*%%%*/
3390
			$$ = new_args($1, 0, $3, 0, $5, $6);
3391
		    /*%
3392
			$$ = params_new($1, Qnil, $3, Qnil, $5, escape_Qundef($6));
3350 3393
		    %*/
3351 3394
		    }
3352 3395
                | f_arg ',' f_rest_arg opt_f_block_arg
3353 3396
		    {
3354 3397
		    /*%%%*/
3355
			$$ = new_args($1, 0, $3, 0, $4);
3398
			$$ = new_args($1, 0, $3, 0, 0, $4);
3356 3399
		    /*%
3357
			$$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
3400
			$$ = params_new($1, Qnil, $3, Qnil, Qnil, escape_Qundef($4));
3358 3401
		    %*/
3359 3402
		    }
3360 3403
		| f_arg ','
3361 3404
		    {
3362 3405
		    /*%%%*/
3363
			$$ = new_args($1, 0, 1, 0, 0);
3406
			$$ = new_args($1, 0, 1, 0, 0, 0);
3364 3407
		    /*%
3365
			$$ = params_new($1, Qnil, Qnil, Qnil, Qnil);
3408
			$$ = params_new($1, Qnil, Qnil, Qnil, Qnil, Qnil);
3366 3409
                        dispatch1(excessed_comma, $$);
3367 3410
		    %*/
3368 3411
		    }
3412
		| f_arg ',' f_rest_arg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3413
		    {
3414
		    /*%%%*/
3415
			$$ = new_args($1, 0, $3, $5, $7, $8);
3416
		    /*%
3417
			$$ = params_new($1, Qnil, $3, $5, $7, escape_Qundef($8));
3418
		    %*/
3419
		    }
3369 3420
		| f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
3370 3421
		    {
3371 3422
		    /*%%%*/
3372
			$$ = new_args($1, 0, $3, $5, $6);
3423
			$$ = new_args($1, 0, $3, $5, 0, $6);
3373 3424
		    /*%
3374
			$$ = params_new($1, Qnil, $3, $5, escape_Qundef($6));
3425
			$$ = params_new($1, Qnil, $3, $5, Qnil, escape_Qundef($6));
3426
		    %*/
3427
		    }
3428
		| f_arg ',' f_block_kwarg opt_f_block_arg
3429
		    {
3430
		    /*%%%*/
3431
			$$ = new_args($1, 0, 0, 0, $3, $4);
3432
		    /*%
3433
			$$ = params_new($1, Qnil,Qnil, Qnil, $3, escape_Qundef($4));
3375 3434
		    %*/
3376 3435
		    }
3377 3436
		| f_arg opt_f_block_arg
3378 3437
		    {
3379 3438
		    /*%%%*/
3380
			$$ = new_args($1, 0, 0, 0, $2);
3439
			$$ = new_args($1, 0, 0, 0, 0, $2);
3381 3440
		    /*%
3382
			$$ = params_new($1, Qnil,Qnil, Qnil, escape_Qundef($2));
3441
			$$ = params_new($1, Qnil,Qnil, Qnil, Qnil, escape_Qundef($2));
3442
		    %*/
3443
		    }
3444
		| f_block_optarg ',' f_rest_arg ',' f_block_kwarg opt_f_block_arg
3445
		    {
3446
		    /*%%%*/
3447
			$$ = new_args(0, $1, $3, 0, $5, $6);
3448
		    /*%
3449
			$$ = params_new(Qnil, $1, $3, Qnil, $5, escape_Qundef($6));
3383 3450
		    %*/
3384 3451
		    }
3385 3452
		| f_block_optarg ',' f_rest_arg opt_f_block_arg
3386 3453
		    {
3387 3454
		    /*%%%*/
3388
			$$ = new_args(0, $1, $3, 0, $4);
3455
			$$ = new_args(0, $1, $3, 0, 0, $4);
3456
		    /*%
3457
			$$ = params_new(Qnil, $1, $3, Qnil, Qnil, escape_Qundef($4));
3458
		    %*/
3459
		    }
3460
		| f_block_optarg ',' f_rest_arg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3461
		    {
3462
		    /*%%%*/
3463
			$$ = new_args(0, $1, $3, $5, $7, $8);
3389 3464
		    /*%
3390
			$$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4));
3465
			$$ = params_new(Qnil, $1, $3, $5, $7, escape_Qundef($8));
3391 3466
		    %*/
3392 3467
		    }
3393 3468
		| f_block_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
3394 3469
		    {
3395 3470
		    /*%%%*/
3396
			$$ = new_args(0, $1, $3, $5, $6);
3471
			$$ = new_args(0, $1, $3, $5, 0, $6);
3397 3472
		    /*%
3398
			$$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6));
3473
			$$ = params_new(Qnil, $1, $3, $5, Qnil, escape_Qundef($6));
3474
		    %*/
3475
		    }
3476
		| f_block_optarg ',' f_block_kwarg opt_f_block_arg
3477
		    {
3478
		    /*%%%*/
3479
			$$ = new_args(0, $1, 0, 0, $3, $4);
3480
		    /*%
3481
			$$ = params_new(Qnil, $1, Qnil, Qnil, $3, escape_Qundef($4));
3399 3482
		    %*/
3400 3483
		    }
3401 3484
		| f_block_optarg opt_f_block_arg
3402 3485
		    {
3403 3486
		    /*%%%*/
3404
			$$ = new_args(0, $1, 0, 0, $2);
3487
			$$ = new_args(0, $1, 0, 0, 0, $2);
3405 3488
		    /*%
3406
			$$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2));
3489
			$$ = params_new(Qnil, $1, Qnil, Qnil, Qnil, escape_Qundef($2));
3490
		    %*/
3491
		    }
3492
		| f_block_optarg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3493
		    {
3494
		    /*%%%*/
3495
			$$ = new_args(0, $1, 0, $3, $5, $6);
3496
		    /*%
3497
			$$ = params_new(Qnil, $1, Qnil, $3, $5, escape_Qundef($6));
3407 3498
		    %*/
3408 3499
		    }
3409 3500
		| f_block_optarg ',' f_arg opt_f_block_arg
3410 3501
		    {
3411 3502
		    /*%%%*/
3412
			$$ = new_args(0, $1, 0, $3, $4);
3503
			$$ = new_args(0, $1, 0, $3, 0, $4);
3413 3504
		    /*%
3414
			$$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4));
3505
			$$ = params_new(Qnil, $1, Qnil, $3, Qnil, escape_Qundef($4));
3506
		    %*/
3507
		    }
3508
		| f_rest_arg ',' f_block_kwarg opt_f_block_arg
3509
		    {
3510
		    /*%%%*/
3511
			$$ = new_args(0, 0, $1, 0, $3, $4);
3512
		    /*%
3513
			$$ = params_new(Qnil, Qnil, $1, Qnil, $3, escape_Qundef($4));
3415 3514
		    %*/
3416 3515
		    }
3417 3516
		| f_rest_arg opt_f_block_arg
3418 3517
		    {
3419 3518
		    /*%%%*/
3420
			$$ = new_args(0, 0, $1, 0, $2);
3519
			$$ = new_args(0, 0, $1, 0, 0, $2);
3421 3520
		    /*%
3422
			$$ = params_new(Qnil, Qnil, $1, Qnil, escape_Qundef($2));
3521
			$$ = params_new(Qnil, Qnil, $1, Qnil, Qnil, escape_Qundef($2));
3522
		    %*/
3523
		    }
3524
		| f_rest_arg ',' f_arg ',' f_block_kwarg opt_f_block_arg
3525
		    {
3526
		    /*%%%*/
3527
			$$ = new_args(0, 0, $1, $3, $5, $6);
3528
		    /*%
3529
			$$ = params_new(Qnil, Qnil, $1, $3, $5, escape_Qundef($6));
3423 3530
		    %*/
3424 3531
		    }
3425 3532
		| f_rest_arg ',' f_arg opt_f_block_arg
3426 3533
		    {
3427 3534
		    /*%%%*/
3428
			$$ = new_args(0, 0, $1, $3, $4);
3535
			$$ = new_args(0, 0, $1, $3, 0, $4);
3536
		    /*%
3537
			$$ = params_new(Qnil, Qnil, $1, $3, Qnil, escape_Qundef($4));
3538
		    %*/
3539
		    }
3540
		| f_block_kwarg opt_f_block_arg
3541
		    {
3542
		    /*%%%*/
3543
			$$ = new_args(0, 0, 0, 0, $1, $2);
3429 3544
		    /*%
3430
			$$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4));
3545
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, $1, escape_Qundef($2));
3431 3546
		    %*/
3432 3547
		    }
3433 3548
		| f_block_arg
3434 3549
		    {
3435 3550
		    /*%%%*/
3436
			$$ = new_args(0, 0, 0, 0, $1);
3551
			$$ = new_args(0, 0, 0, 0, 0, $1);
3437 3552
		    /*%
3438
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, $1);
3553
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil, $1);
3439 3554
		    %*/
3440 3555
		    }
3441 3556
		;
......
3452 3567
		    /*%%%*/
3453 3568
			$$ = 0;
3454 3569
		    /*%
3455
			$$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil),
3570
			$$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil),
3456 3571
                                          escape_Qundef($2));
3457 3572
		    %*/
3458 3573
		    }
......
3461 3576
		    /*%%%*/
3462 3577
			$$ = 0;
3463 3578
		    /*%
3464
			$$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil),
3579
			$$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil,Qnil),
3465 3580
                                          Qnil);
3466 3581
		    %*/
3467 3582
		    }
......
4376 4491
		    }
4377 4492
		;
4378 4493

  
4379
f_args		: f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
4494
f_args		: f_arg ',' f_optarg ',' f_rest_arg ',' f_kwarg opt_f_block_arg
4495
		    {
4496
		    /*%%%*/
4497
			$$ = new_args($1, $3, $5, 0, $7, $8);
4498
		    /*%
4499
			$$ = params_new($1, $3, $5, Qnil, $7, escape_Qundef($8));
4500
		    %*/
4501
		    }
4502
		| f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
4503
		    {
4504
		    /*%%%*/
4505
			$$ = new_args($1, $3, $5, 0, 0, $6);
4506
		    /*%
4507
			$$ = params_new($1, $3, $5, Qnil, Qnil, escape_Qundef($6));
4508
		    %*/
4509
		    }
4510
		| f_arg ',' f_optarg ',' f_rest_arg ',' f_arg ',' f_kwarg opt_f_block_arg
4380 4511
		    {
4381 4512
		    /*%%%*/
4382
			$$ = new_args($1, $3, $5, 0, $6);
4513
			$$ = new_args($1, $3, $5, $7, $9, $10);
4383 4514
		    /*%
4384
			$$ = params_new($1, $3, $5, Qnil, escape_Qundef($6));
4515
			$$ = params_new($1, $3, $5, $7, $9, escape_Qundef($10));
4385 4516
		    %*/
4386 4517
		    }
4387 4518
		| f_arg ',' f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
4388 4519
		    {
4389 4520
		    /*%%%*/
4390
			$$ = new_args($1, $3, $5, $7, $8);
4521
			$$ = new_args($1, $3, $5, $7, 0, $8);
4391 4522
		    /*%
4392
			$$ = params_new($1, $3, $5, $7, escape_Qundef($8));
4523
			$$ = params_new($1, $3, $5, $7, Qnil, escape_Qundef($8));
4524
		    %*/
4525
		    }
4526
		| f_arg ',' f_optarg ',' f_kwarg opt_f_block_arg
4527
		    {
4528
		    /*%%%*/
4529
			$$ = new_args($1, $3, 0, 0, $5, $6);
4530
		    /*%
4531
			$$ = params_new($1, $3, Qnil, Qnil, $5, escape_Qundef($6));
4393 4532
		    %*/
4394 4533
		    }
4395 4534
		| f_arg ',' f_optarg opt_f_block_arg
4396 4535
		    {
4397 4536
		    /*%%%*/
4398
			$$ = new_args($1, $3, 0, 0, $4);
4537
			$$ = new_args($1, $3, 0, 0, 0, $4);
4399 4538
		    /*%
4400
			$$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4));
4539
			$$ = params_new($1, $3, Qnil, Qnil, Qnil, escape_Qundef($4));
4540
		    %*/
4541
		    }
4542
		| f_arg ',' f_optarg ',' f_arg ',' f_kwarg opt_f_block_arg
4543
		    {
4544
		    /*%%%*/
4545
			$$ = new_args($1, $3, 0, $5, $7, $8);
4546
		    /*%
4547
			$$ = params_new($1, $3, Qnil, $5, $7, escape_Qundef($8));
4401 4548
		    %*/
4402 4549
		    }
4403 4550
		| f_arg ',' f_optarg ',' f_arg opt_f_block_arg
4404 4551
		    {
4405 4552
		    /*%%%*/
4406
			$$ = new_args($1, $3, 0, $5, $6);
4553
			$$ = new_args($1, $3, 0, $5, 0, $6);
4554
		    /*%
4555
			$$ = params_new($1, $3, Qnil, $5, Qnil, escape_Qundef($6));
4556
		    %*/
4557
		    }
4558
		| f_arg ',' f_rest_arg ',' f_kwarg opt_f_block_arg
4559
		    {
4560
		    /*%%%*/
4561
			$$ = new_args($1, 0, $3, 0, $5, $6);
4407 4562
		    /*%
4408
			$$ = params_new($1, $3, Qnil, $5, escape_Qundef($6));
4563
			$$ = params_new($1, Qnil, $3, Qnil, $5, escape_Qundef($6));
4409 4564
		    %*/
4410 4565
		    }
4411 4566
		| f_arg ',' f_rest_arg opt_f_block_arg
4412 4567
		    {
4413 4568
		    /*%%%*/
4414
			$$ = new_args($1, 0, $3, 0, $4);
4569
			$$ = new_args($1, 0, $3, 0, 0, $4);
4415 4570
		    /*%
4416
			$$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4));
4571
			$$ = params_new($1, Qnil, $3, Qnil, Qnil, escape_Qundef($4));
4572
		    %*/
4573
		    }
4574
		| f_arg ',' f_rest_arg ',' f_arg ',' f_kwarg opt_f_block_arg
4575
		    {
4576
		    /*%%%*/
4577
			$$ = new_args($1, 0, $3, $5, $7, $8);
4578
		    /*%
4579
			$$ = params_new($1, Qnil, $3, $5, $7, escape_Qundef($8));
4417 4580
		    %*/
4418 4581
		    }
4419 4582
		| f_arg ',' f_rest_arg ',' f_arg opt_f_block_arg
4420 4583
		    {
4421 4584
		    /*%%%*/
4422
			$$ = new_args($1, 0, $3, $5, $6);
4585
			$$ = new_args($1, 0, $3, $5, 0, $6);
4586
		    /*%
4587
			$$ = params_new($1, Qnil, $3, $5, Qnil, escape_Qundef($6));
4588
		    %*/
4589
		    }
4590
		| f_arg ',' f_kwarg opt_f_block_arg
4591
		    {
4592
		    /*%%%*/
4593
			$$ = new_args($1, 0, 0, 0, $3, $4);
4423 4594
		    /*%
4424
			$$ = params_new($1, Qnil, $3, $5, escape_Qundef($6));
4595
			$$ = params_new($1, Qnil, Qnil, Qnil, $3, escape_Qundef($4));
4425 4596
		    %*/
4426 4597
		    }
4427 4598
		| f_arg opt_f_block_arg
4428 4599
		    {
4429 4600
		    /*%%%*/
4430
			$$ = new_args($1, 0, 0, 0, $2);
4601
			$$ = new_args($1, 0, 0, 0, 0, $2);
4431 4602
		    /*%
4432
			$$ = params_new($1, Qnil, Qnil, Qnil,escape_Qundef($2));
4603
			$$ = params_new($1, Qnil, Qnil, Qnil, Qnil, escape_Qundef($2));
4604
		    %*/
4605
		    }
4606
		| f_optarg ',' f_rest_arg ',' f_kwarg opt_f_block_arg
4607
		    {
4608
		    /*%%%*/
4609
			$$ = new_args(0, $1, $3, 0, $5, $6);
4610
		    /*%
4611
			$$ = params_new(Qnil, $1, $3, Qnil, $5, escape_Qundef($6));
4433 4612
		    %*/
4434 4613
		    }
4435 4614
		| f_optarg ',' f_rest_arg opt_f_block_arg
4436 4615
		    {
4437 4616
		    /*%%%*/
4438
			$$ = new_args(0, $1, $3, 0, $4);
4617
			$$ = new_args(0, $1, $3, 0, 0, $4);
4618
		    /*%
4619
			$$ = params_new(Qnil, $1, $3, Qnil, Qnil, escape_Qundef($4));
4620
		    %*/
4621
		    }
4622
		| f_optarg ',' f_rest_arg ',' f_arg ',' f_kwarg opt_f_block_arg
4623
		    {
4624
		    /*%%%*/
4625
			$$ = new_args(0, $1, $3, $5, $7, $8);
4439 4626
		    /*%
4440
			$$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4));
4627
			$$ = params_new(Qnil, $1, $3, $5, $7, escape_Qundef($8));
4441 4628
		    %*/
4442 4629
		    }
4443 4630
		| f_optarg ',' f_rest_arg ',' f_arg opt_f_block_arg
4444 4631
		    {
4445 4632
		    /*%%%*/
4446
			$$ = new_args(0, $1, $3, $5, $6);
4633
			$$ = new_args(0, $1, $3, $5, 0, $6);
4447 4634
		    /*%
4448
			$$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6));
4635
			$$ = params_new(Qnil, $1, $3, $5, Qnil, escape_Qundef($6));
4636
		    %*/
4637
		    }
4638
		| f_optarg ',' f_kwarg opt_f_block_arg
4639
		    {
4640
		    /*%%%*/
4641
			$$ = new_args(0, $1, 0, 0, $3, $4);
4642
		    /*%
4643
			$$ = params_new(Qnil, $1, Qnil, Qnil, $3, escape_Qundef($4));
4449 4644
		    %*/
4450 4645
		    }
4451 4646
		| f_optarg opt_f_block_arg
4452 4647
		    {
4453 4648
		    /*%%%*/
4454
			$$ = new_args(0, $1, 0, 0, $2);
4649
			$$ = new_args(0, $1, 0, 0, 0, $2);
4455 4650
		    /*%
4456
			$$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2));
4651
			$$ = params_new(Qnil, $1, Qnil, Qnil, Qnil, escape_Qundef($2));
4652
		    %*/
4653
		    }
4654
		| f_optarg ',' f_arg ',' f_kwarg opt_f_block_arg
4655
		    {
4656
		    /*%%%*/
4657
			$$ = new_args(0, $1, 0, $3, $5, $6);
4658
		    /*%
4659
			$$ = params_new(Qnil, $1, Qnil, $3, $5, escape_Qundef($6));
4457 4660
		    %*/
4458 4661
		    }
4459 4662
		| f_optarg ',' f_arg opt_f_block_arg
4460 4663
		    {
4461 4664
		    /*%%%*/
4462
			$$ = new_args(0, $1, 0, $3, $4);
4665
			$$ = new_args(0, $1, 0, $3, 0, $4);
4463 4666
		    /*%
4464
			$$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4));
4667
			$$ = params_new(Qnil, $1, Qnil, $3, Qnil, escape_Qundef($4));
4668
		    %*/
4669
		    }
4670
		| f_rest_arg ',' f_kwarg opt_f_block_arg
4671
		    {
4672
		    /*%%%*/
4673
			$$ = new_args(0, 0, $1, 0, $3, $4);
4674
		    /*%
4675
			$$ = params_new(Qnil, Qnil, $1, Qnil, $3, escape_Qundef($4));
4465 4676
		    %*/
4466 4677
		    }
4467 4678
		| f_rest_arg opt_f_block_arg
4468 4679
		    {
4469 4680
		    /*%%%*/
4470
			$$ = new_args(0, 0, $1, 0, $2);
4681
			$$ = new_args(0, 0, $1, 0, 0, $2);
4471 4682
		    /*%
4472
			$$ = params_new(Qnil, Qnil, $1, Qnil,escape_Qundef($2));
4683
			$$ = params_new(Qnil, Qnil, $1, Qnil, Qnil, escape_Qundef($2));
4684
		    %*/
4685
		    }
4686
		| f_rest_arg ',' f_arg ',' f_kwarg opt_f_block_arg
4687
		    {
4688
		    /*%%%*/
4689
			$$ = new_args(0, 0, $1, $3, $5, $6);
4690
		    /*%
4691
			$$ = params_new(Qnil, Qnil, $1, $3, $5, escape_Qundef($6));
4473 4692
		    %*/
4474 4693
		    }
4475 4694
		| f_rest_arg ',' f_arg opt_f_block_arg
4476 4695
		    {
4477 4696
		    /*%%%*/
4478
			$$ = new_args(0, 0, $1, $3, $4);
4697
			$$ = new_args(0, 0, $1, $3, 0, $4);
4698
		    /*%
4699
			$$ = params_new(Qnil, Qnil, $1, $3,  Qnil, escape_Qundef($4));
4700
		    %*/
4701
		    }
4702
		| f_kwarg opt_f_block_arg
4703
		    {
4704
		    /*%%%*/
4705
			$$ = new_args(0, 0, 0, 0, $1, $2);
4479 4706
		    /*%
4480
			$$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4));
4707
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, $1, escape_Qundef($2));
4481 4708
		    %*/
4482 4709
		    }
4483 4710
		| f_block_arg
4484 4711
		    {
4485 4712
		    /*%%%*/
4486
			$$ = new_args(0, 0, 0, 0, $1);
4713
			$$ = new_args(0, 0, 0, 0, 0, $1);
4487 4714
		    /*%
4488
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, $1);
4715
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil, $1);
4489 4716
		    %*/
4490 4717
		    }
4491 4718
		| /* none */
4492 4719
		    {
4493 4720
		    /*%%%*/
4494
			$$ = new_args(0, 0, 0, 0, 0);
4721
			$$ = new_args(0, 0, 0, 0, 0, 0);
4495 4722
		    /*%
4496
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil);
4723
			$$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil, Qnil);
4497 4724
		    %*/
4498 4725
		    }
4499 4726
		;
......
4592 4819
		    }
4593 4820
		;
4594 4821

  
4822
f_kw		: tLABEL arg_value
4823
		    {
4824
			arg_var(formal_argument(get_id($1)));
4825
			$$ = assignable($1, $2);
4826
		    /*%%%*/
4827
			$$ = NEW_KW_ARG(0, $$);
4828
		    /*%
4829
			$$ = rb_assoc_new($$, $2);
4830
		    %*/
4831
		    }
4832
		;
4833

  
4834
f_block_kw	: tLABEL primary_value
4835
		    {
4836
			arg_var(formal_argument(get_id($1)));
4837
			$$ = assignable($1, $2);
4838
		    /*%%%*/
4839
			$$ = NEW_KW_ARG(0, $$);
4840
		    /*%
4841
			$$ = rb_assoc_new($$, $2);
4842
		    %*/
4843
		    }
4844
		;
4845

  
4846
f_block_kwarg	: f_block_kw
4847
		    {
4848
		    /*%%%*/
4849
			$$ = $1;
4850
		    /*%
4851
			$$ = rb_ary_new3(1, $1);
4852
		    %*/
4853
		    }
4854
		| f_block_kwarg ',' f_block_kw
4855
		    {
4856
		    /*%%%*/
4857
			NODE *kws = $1;
4858

  
4859
			while (kws->nd_next) {
4860
			    kws = kws->nd_next;
4861
			}
4862
			kws->nd_next = $3;
4863
			$$ = $1;
4864
		    /*%
4865
			$$ = rb_ary_push($1, $3);
4866
		    %*/
4867
		    }
4868
		;
4869

  
4870

  
4871
f_kwarg		: f_kw
4872
		    {
4873
		    /*%%%*/
4874
			$$ = $1;
4875
		    /*%
4876
			$$ = rb_ary_new3(1, $1);
4877
		    %*/
4878
		    }
4879
		| f_kwarg ',' f_kw
4880
		    {
4881
		    /*%%%*/
4882
			NODE *kws = $1;
4883

  
4884
			while (kws->nd_next) {
4885
			    kws = kws->nd_next;
4886
			}
4887
			kws->nd_next = $3;
4888
			$$ = $1;
4889
		    /*%
4890
			$$ = rb_ary_push($1, $3);
4891
		    %*/
4892
		    }
4893
		;
4894

  
4595 4895
f_opt		: tIDENTIFIER '=' arg_value
4596 4896
		    {
4597 4897
			arg_var(formal_argument(get_id($1)));
......
9066 9366
}
9067 9367

  
9068 9368
static NODE*
9069
new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, ID b)
9369
new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *k, ID b)
9070 9370
{
9071 9371
    int saved_line = ruby_sourceline;
9072 9372
    struct rb_args_info *args;
......
9083 9383
    args->rest_arg       = r;
9084 9384
    args->block_arg      = b;
9085 9385

  
9386
    args->kw_args        = k;
9086 9387
    args->opt_args       = o;
9087 9388

  
9088 9389
    ruby_sourceline = saved_line;
......
10601 10902
    return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
10602 10903
}
10603 10904

  
10905
static VALUE
10906
ripper_dispatch6(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e, VALUE f)
10907
{
10908
    validate(a);
10909
    validate(b);
10910
    validate(c);
10911
    validate(d);
10912
    validate(e);
10913
    validate(f);
10914
    return rb_funcall(parser->value, mid, 6, a, b, c, d, e, f);
10915
}
10916

  
10604 10917
static const struct kw_assoc {
10605 10918
    ID id;
10606 10919
    const char *name;
10607
-