parse.y: `__ENCODING__` should be determined in run-time; fix
It used to be compiled to the static string in the compiler. But the
encoding status actually depends on the runtime configuration. A new
method `Kernel#__ENCODING__` is introduced to implement the feature.
MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -3587,12 +3587,7 @@ var_ref : variable
}
| keyword__ENCODING__
{
-#ifdef MRB_UTF8_STRING
- const char *enc = "UTF-8";
-#else
- const char *enc = "ASCII-8BIT";
-#endif
- $$ = new_str(p, enc, strlen(enc));
+ $$ = new_fcall(p, MRB_SYM_2(p->mrb, __ENCODING__), 0);
}
;

MODIFY
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
@@ -2080,18 +2080,18 @@ static const yytype_int16 yyrline[] =
3424, 3438, 3442, 3456, 3461, 3475, 3481, 3482, 3483, 3484,
3485, 3489, 3495, 3499, 3509, 3510, 3511, 3515, 3521, 3525,
3529, 3533, 3537, 3543, 3547, 3553, 3557, 3561, 3565, 3569,
- 3573, 3581, 3588, 3599, 3600, 3604, 3608, 3607, 3624, 3625,
- 3628, 3634, 3652, 3672, 3673, 3679, 3685, 3691, 3698, 3703,
- 3710, 3714, 3720, 3724, 3730, 3731, 3734, 3738, 3744, 3748,
- 3752, 3756, 3762, 3767, 3772, 3776, 3780, 3784, 3788, 3792,
- 3796, 3800, 3804, 3808, 3812, 3816, 3820, 3824, 3829, 3835,
- 3840, 3845, 3850, 3855, 3862, 3866, 3873, 3878, 3877, 3889,
- 3893, 3899, 3907, 3915, 3923, 3927, 3933, 3937, 3943, 3944,
- 3947, 3952, 3959, 3960, 3963, 3969, 3973, 3979, 3984, 3984,
- 4009, 4010, 4016, 4021, 4027, 4033, 4038, 4042, 4052, 4059,
- 4060, 4061, 4064, 4065, 4066, 4067, 4070, 4071, 4072, 4075,
- 4076, 4079, 4083, 4089, 4090, 4096, 4097, 4100, 4101, 4104,
- 4107, 4108, 4109, 4112, 4113, 4116, 4121, 4124, 4125, 4129
+ 3573, 3581, 3588, 3594, 3595, 3599, 3603, 3602, 3619, 3620,
+ 3623, 3629, 3647, 3667, 3668, 3674, 3680, 3686, 3693, 3698,
+ 3705, 3709, 3715, 3719, 3725, 3726, 3729, 3733, 3739, 3743,
+ 3747, 3751, 3757, 3762, 3767, 3771, 3775, 3779, 3783, 3787,
+ 3791, 3795, 3799, 3803, 3807, 3811, 3815, 3819, 3824, 3830,
+ 3835, 3840, 3845, 3850, 3857, 3861, 3868, 3873, 3872, 3884,
+ 3888, 3894, 3902, 3910, 3918, 3922, 3928, 3932, 3938, 3939,
+ 3942, 3947, 3954, 3955, 3958, 3964, 3968, 3974, 3979, 3979,
+ 4004, 4005, 4011, 4016, 4022, 4028, 4033, 4037, 4047, 4054,
+ 4055, 4056, 4059, 4060, 4061, 4062, 4065, 4066, 4067, 4070,
+ 4071, 4074, 4078, 4084, 4085, 4091, 4092, 4095, 4096, 4099,
+ 4102, 4103, 4104, 4107, 4108, 4111, 4116, 4119, 4120, 4124
};
#endif
@@ -9285,53 +9285,48 @@ yyreduce:
case 492:
#line 3589 "mrbgems/mruby-compiler/core/parse.y"
{
-#ifdef MRB_UTF8_STRING
- const char *enc = "UTF-8";
-#else
- const char *enc = "ASCII-8BIT";
-#endif
- (yyval.nd) = new_str(p, enc, strlen(enc));
+ (yyval.nd) = new_fcall(p, MRB_SYM_2(p->mrb, __ENCODING__), 0);
}
-#line 9296 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9291 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 495:
-#line 3604 "mrbgems/mruby-compiler/core/parse.y"
+#line 3599 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = 0;
}
-#line 9304 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9299 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 496:
-#line 3608 "mrbgems/mruby-compiler/core/parse.y"
+#line 3603 "mrbgems/mruby-compiler/core/parse.y"
{
p->lstate = EXPR_BEG;
p->cmd_start = TRUE;
}
-#line 9313 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9308 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 497:
-#line 3613 "mrbgems/mruby-compiler/core/parse.y"
+#line 3608 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[-1].nd);
}
-#line 9321 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9316 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 500:
-#line 3629 "mrbgems/mruby-compiler/core/parse.y"
+#line 3624 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[-1].nd);
p->lstate = EXPR_BEG;
p->cmd_start = TRUE;
}
-#line 9331 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9326 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 501:
-#line 3635 "mrbgems/mruby-compiler/core/parse.y"
+#line 3630 "mrbgems/mruby-compiler/core/parse.y"
{
#if 1
/* til real keyword args implemented */
@@ -9349,11 +9344,11 @@ yyreduce:
new_args_tail(p, 0, new_kw_rest_args(p, nsym(k)), b));
#endif
}
-#line 9353 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9348 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 502:
-#line 3653 "mrbgems/mruby-compiler/core/parse.y"
+#line 3648 "mrbgems/mruby-compiler/core/parse.y"
{
#if 1
/* til real keyword args implemented */
@@ -9371,504 +9366,504 @@ yyreduce:
new_args_tail(p, 0, new_kw_rest_args(p, nsym(k)), b));
#endif
}
-#line 9375 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9370 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 504:
-#line 3674 "mrbgems/mruby-compiler/core/parse.y"
+#line 3669 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[-1].nd);
}
-#line 9383 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9378 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 505:
-#line 3680 "mrbgems/mruby-compiler/core/parse.y"
+#line 3675 "mrbgems/mruby-compiler/core/parse.y"
{
local_nest(p);
}
-#line 9391 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9386 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 506:
-#line 3686 "mrbgems/mruby-compiler/core/parse.y"
+#line 3681 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = new_kw_arg(p, (yyvsp[-1].id), cons((yyvsp[0].nd), locals_node(p)));
local_unnest(p);
}
-#line 9401 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9396 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 507:
-#line 3692 "mrbgems/mruby-compiler/core/parse.y"
+#line 3687 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_kw_arg(p, (yyvsp[0].id), 0);
local_unnest(p);
}
-#line 9410 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9405 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 508:
-#line 3699 "mrbgems/mruby-compiler/core/parse.y"
+#line 3694 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_kw_arg(p, (yyvsp[-1].id), cons((yyvsp[0].nd), locals_node(p)));
local_unnest(p);
}
-#line 9419 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9414 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 509:
-#line 3704 "mrbgems/mruby-compiler/core/parse.y"
+#line 3699 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_kw_arg(p, (yyvsp[0].id), 0);
local_unnest(p);
}
-#line 9428 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9423 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 510:
-#line 3711 "mrbgems/mruby-compiler/core/parse.y"
+#line 3706 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
}
-#line 9436 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9431 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 511:
-#line 3715 "mrbgems/mruby-compiler/core/parse.y"
+#line 3710 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9444 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9439 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 512:
-#line 3721 "mrbgems/mruby-compiler/core/parse.y"
+#line 3716 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
}
-#line 9452 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9447 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 513:
-#line 3725 "mrbgems/mruby-compiler/core/parse.y"
+#line 3720 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9460 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9455 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 516:
-#line 3735 "mrbgems/mruby-compiler/core/parse.y"
+#line 3730 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_kw_rest_args(p, nsym((yyvsp[0].id)));
}
-#line 9468 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9463 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 517:
-#line 3739 "mrbgems/mruby-compiler/core/parse.y"
+#line 3734 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_kw_rest_args(p, 0);
}
-#line 9476 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9471 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 518:
-#line 3745 "mrbgems/mruby-compiler/core/parse.y"
+#line 3740 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args_tail(p, (yyvsp[-3].nd), (yyvsp[-1].nd), (yyvsp[0].id));
}
-#line 9484 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9479 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 519:
-#line 3749 "mrbgems/mruby-compiler/core/parse.y"
+#line 3744 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args_tail(p, (yyvsp[-1].nd), 0, (yyvsp[0].id));
}
-#line 9492 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9487 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 520:
-#line 3753 "mrbgems/mruby-compiler/core/parse.y"
+#line 3748 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args_tail(p, 0, (yyvsp[-1].nd), (yyvsp[0].id));
}
-#line 9500 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9495 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 521:
-#line 3757 "mrbgems/mruby-compiler/core/parse.y"
+#line 3752 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args_tail(p, 0, 0, (yyvsp[0].id));
}
-#line 9508 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9503 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 522:
-#line 3763 "mrbgems/mruby-compiler/core/parse.y"
+#line 3758 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[0].nd);
}
-#line 9516 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9511 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 523:
-#line 3767 "mrbgems/mruby-compiler/core/parse.y"
+#line 3762 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args_tail(p, 0, 0, 0);
}
-#line 9524 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9519 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 524:
-#line 3773 "mrbgems/mruby-compiler/core/parse.y"
+#line 3768 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-5].nd), (yyvsp[-3].nd), (yyvsp[-1].id), 0, (yyvsp[0].nd));
}
-#line 9532 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9527 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 525:
-#line 3777 "mrbgems/mruby-compiler/core/parse.y"
+#line 3772 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-7].nd), (yyvsp[-5].nd), (yyvsp[-3].id), (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9540 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9535 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 526:
-#line 3781 "mrbgems/mruby-compiler/core/parse.y"
+#line 3776 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-3].nd), (yyvsp[-1].nd), 0, 0, (yyvsp[0].nd));
}
-#line 9548 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9543 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 527:
-#line 3785 "mrbgems/mruby-compiler/core/parse.y"
+#line 3780 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-5].nd), (yyvsp[-3].nd), 0, (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9556 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9551 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 528:
-#line 3789 "mrbgems/mruby-compiler/core/parse.y"
+#line 3784 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-3].nd), 0, (yyvsp[-1].id), 0, (yyvsp[0].nd));
}
-#line 9564 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9559 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 529:
-#line 3793 "mrbgems/mruby-compiler/core/parse.y"
+#line 3788 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-5].nd), 0, (yyvsp[-3].id), (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9572 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9567 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 530:
-#line 3797 "mrbgems/mruby-compiler/core/parse.y"
+#line 3792 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, (yyvsp[-1].nd), 0, 0, 0, (yyvsp[0].nd));
}
-#line 9580 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9575 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 531:
-#line 3801 "mrbgems/mruby-compiler/core/parse.y"
+#line 3796 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, (yyvsp[-3].nd), (yyvsp[-1].id), 0, (yyvsp[0].nd));
}
-#line 9588 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9583 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 532:
-#line 3805 "mrbgems/mruby-compiler/core/parse.y"
+#line 3800 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, (yyvsp[-5].nd), (yyvsp[-3].id), (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9596 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9591 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 533:
-#line 3809 "mrbgems/mruby-compiler/core/parse.y"
+#line 3804 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, (yyvsp[-1].nd), 0, 0, (yyvsp[0].nd));
}
-#line 9604 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9599 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 534:
-#line 3813 "mrbgems/mruby-compiler/core/parse.y"
+#line 3808 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, (yyvsp[-3].nd), 0, (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9612 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9607 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 535:
-#line 3817 "mrbgems/mruby-compiler/core/parse.y"
+#line 3812 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, 0, (yyvsp[-1].id), 0, (yyvsp[0].nd));
}
-#line 9620 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9615 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 536:
-#line 3821 "mrbgems/mruby-compiler/core/parse.y"
+#line 3816 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, 0, (yyvsp[-3].id), (yyvsp[-1].nd), (yyvsp[0].nd));
}
-#line 9628 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9623 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 537:
-#line 3825 "mrbgems/mruby-compiler/core/parse.y"
+#line 3820 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_args(p, 0, 0, 0, 0, (yyvsp[0].nd));
}
-#line 9636 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9631 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 538:
-#line 3829 "mrbgems/mruby-compiler/core/parse.y"
+#line 3824 "mrbgems/mruby-compiler/core/parse.y"
{
local_add_f(p, intern_op(and));
(yyval.nd) = new_args(p, 0, 0, 0, 0, 0);
}
-#line 9645 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9640 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 539:
-#line 3836 "mrbgems/mruby-compiler/core/parse.y"
+#line 3831 "mrbgems/mruby-compiler/core/parse.y"
{
yyerror(p, "formal argument cannot be a constant");
(yyval.nd) = 0;
}
-#line 9654 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9649 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 540:
-#line 3841 "mrbgems/mruby-compiler/core/parse.y"
+#line 3836 "mrbgems/mruby-compiler/core/parse.y"
{
yyerror(p, "formal argument cannot be an instance variable");
(yyval.nd) = 0;
}
-#line 9663 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9658 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 541:
-#line 3846 "mrbgems/mruby-compiler/core/parse.y"
+#line 3841 "mrbgems/mruby-compiler/core/parse.y"
{
yyerror(p, "formal argument cannot be a global variable");
(yyval.nd) = 0;
}
-#line 9672 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9667 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 542:
-#line 3851 "mrbgems/mruby-compiler/core/parse.y"
+#line 3846 "mrbgems/mruby-compiler/core/parse.y"
{
yyerror(p, "formal argument cannot be a class variable");
(yyval.nd) = 0;
}
-#line 9681 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9676 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 543:
-#line 3856 "mrbgems/mruby-compiler/core/parse.y"
+#line 3851 "mrbgems/mruby-compiler/core/parse.y"
{
yyerror(p, "formal argument cannot be a numbered parameter");
(yyval.nd) = 0;
}
-#line 9690 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9685 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 544:
-#line 3863 "mrbgems/mruby-compiler/core/parse.y"
+#line 3858 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.id) = 0;
}
-#line 9698 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9693 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 545:
-#line 3867 "mrbgems/mruby-compiler/core/parse.y"
+#line 3862 "mrbgems/mruby-compiler/core/parse.y"
{
local_add_f(p, (yyvsp[0].id));
(yyval.id) = (yyvsp[0].id);
}
-#line 9707 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9702 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 546:
-#line 3874 "mrbgems/mruby-compiler/core/parse.y"
+#line 3869 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_arg(p, (yyvsp[0].id));
}
-#line 9715 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9710 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 547:
-#line 3878 "mrbgems/mruby-compiler/core/parse.y"
+#line 3873 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = local_switch(p);
}
-#line 9723 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9718 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 548:
-#line 3882 "mrbgems/mruby-compiler/core/parse.y"
+#line 3877 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = new_masgn_param(p, (yyvsp[-1].nd), p->locals->car);
local_resume(p, (yyvsp[-2].nd));
local_add_f(p, 0);
}
-#line 9733 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9728 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 549:
-#line 3890 "mrbgems/mruby-compiler/core/parse.y"
+#line 3885 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
}
-#line 9741 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9736 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 550:
-#line 3894 "mrbgems/mruby-compiler/core/parse.y"
+#line 3889 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9749 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9744 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 551:
-#line 3900 "mrbgems/mruby-compiler/core/parse.y"
+#line 3895 "mrbgems/mruby-compiler/core/parse.y"
{
local_add_f(p, (yyvsp[-1].id));
local_nest(p);
(yyval.id) = (yyvsp[-1].id);
}
-#line 9759 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9754 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 552:
-#line 3908 "mrbgems/mruby-compiler/core/parse.y"
+#line 3903 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = cons(nsym((yyvsp[-1].id)), cons((yyvsp[0].nd), locals_node(p)));
local_unnest(p);
}
-#line 9769 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9764 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 553:
-#line 3916 "mrbgems/mruby-compiler/core/parse.y"
+#line 3911 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = cons(nsym((yyvsp[-1].id)), cons((yyvsp[0].nd), locals_node(p)));
local_unnest(p);
}
-#line 9779 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9774 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 554:
-#line 3924 "mrbgems/mruby-compiler/core/parse.y"
+#line 3919 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
}
-#line 9787 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9782 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 555:
-#line 3928 "mrbgems/mruby-compiler/core/parse.y"
+#line 3923 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9795 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9790 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 556:
-#line 3934 "mrbgems/mruby-compiler/core/parse.y"
+#line 3929 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
}
-#line 9803 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9798 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 557:
-#line 3938 "mrbgems/mruby-compiler/core/parse.y"
+#line 3933 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9811 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9806 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 560:
-#line 3948 "mrbgems/mruby-compiler/core/parse.y"
+#line 3943 "mrbgems/mruby-compiler/core/parse.y"
{
local_add_f(p, (yyvsp[0].id));
(yyval.id) = (yyvsp[0].id);
}
-#line 9820 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9815 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 561:
-#line 3953 "mrbgems/mruby-compiler/core/parse.y"
+#line 3948 "mrbgems/mruby-compiler/core/parse.y"
{
local_add_f(p, intern_op(mul));
(yyval.id) = -1;
}
-#line 9829 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9824 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 564:
-#line 3964 "mrbgems/mruby-compiler/core/parse.y"
+#line 3959 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.id) = (yyvsp[0].id);
}
-#line 9837 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9832 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 565:
-#line 3970 "mrbgems/mruby-compiler/core/parse.y"
+#line 3965 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.id) = (yyvsp[0].id);
}
-#line 9845 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9840 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 566:
-#line 3974 "mrbgems/mruby-compiler/core/parse.y"
+#line 3969 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.id) = 0;
}
-#line 9853 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9848 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 567:
-#line 3980 "mrbgems/mruby-compiler/core/parse.y"
+#line 3975 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[0].nd);
if (!(yyval.nd)) (yyval.nd) = new_nil(p);
}
-#line 9862 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9857 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 568:
-#line 3984 "mrbgems/mruby-compiler/core/parse.y"
+#line 3979 "mrbgems/mruby-compiler/core/parse.y"
{p->lstate = EXPR_BEG;}
-#line 9868 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9863 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 569:
-#line 3985 "mrbgems/mruby-compiler/core/parse.y"
+#line 3980 "mrbgems/mruby-compiler/core/parse.y"
{
if ((yyvsp[-1].nd) == 0) {
yyerror(p, "can't define singleton method for ().");
@@ -9891,63 +9886,63 @@ yyreduce:
}
(yyval.nd) = (yyvsp[-1].nd);
}
-#line 9895 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9890 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 571:
-#line 4011 "mrbgems/mruby-compiler/core/parse.y"
+#line 4006 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = (yyvsp[-1].nd);
}
-#line 9903 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9898 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 572:
-#line 4017 "mrbgems/mruby-compiler/core/parse.y"
+#line 4012 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = list1((yyvsp[0].nd));
NODE_LINENO((yyval.nd), (yyvsp[0].nd));
}
-#line 9912 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9907 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 573:
-#line 4022 "mrbgems/mruby-compiler/core/parse.y"
+#line 4017 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = push((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9920 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9915 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 574:
-#line 4028 "mrbgems/mruby-compiler/core/parse.y"
+#line 4023 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[-2].nd));
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = cons((yyvsp[-2].nd), (yyvsp[0].nd));
}
-#line 9930 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9925 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 575:
-#line 4034 "mrbgems/mruby-compiler/core/parse.y"
+#line 4029 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = cons(new_sym(p, (yyvsp[-2].id)), (yyvsp[0].nd));
}
-#line 9939 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9934 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 576:
-#line 4039 "mrbgems/mruby-compiler/core/parse.y"
+#line 4034 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = cons(new_sym(p, (yyvsp[-1].id)), label_reference(p, (yyvsp[-1].id)));
}
-#line 9947 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9942 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 577:
-#line 4043 "mrbgems/mruby-compiler/core/parse.y"
+#line 4038 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
if (typen((yyvsp[-2].nd)->car) == NODE_DSTR) {
@@ -9957,67 +9952,67 @@ yyreduce:
(yyval.nd) = cons(new_sym(p, new_strsym(p, (yyvsp[-2].nd))), (yyvsp[0].nd));
}
}
-#line 9961 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9956 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 578:
-#line 4053 "mrbgems/mruby-compiler/core/parse.y"
+#line 4048 "mrbgems/mruby-compiler/core/parse.y"
{
void_expr_error(p, (yyvsp[0].nd));
(yyval.nd) = cons(new_kw_rest_args(p, 0), (yyvsp[0].nd));
}
-#line 9970 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9965 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 591:
-#line 4080 "mrbgems/mruby-compiler/core/parse.y"
+#line 4075 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.num) = '.';
}
-#line 9978 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9973 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 592:
-#line 4084 "mrbgems/mruby-compiler/core/parse.y"
+#line 4079 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.num) = 0;
}
-#line 9986 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9981 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 594:
-#line 4091 "mrbgems/mruby-compiler/core/parse.y"
+#line 4086 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.num) = tCOLON2;
}
-#line 9994 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9989 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 603:
-#line 4112 "mrbgems/mruby-compiler/core/parse.y"
+#line 4107 "mrbgems/mruby-compiler/core/parse.y"
{yyerrok;}
-#line 10000 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 9995 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 605:
-#line 4117 "mrbgems/mruby-compiler/core/parse.y"
+#line 4112 "mrbgems/mruby-compiler/core/parse.y"
{
p->lineno += (yyvsp[0].num);
p->column = 0;
}
-#line 10009 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 10004 "mrbgems/mruby-compiler/core/y.tab.c"
break;
case 609:
-#line 4129 "mrbgems/mruby-compiler/core/parse.y"
+#line 4124 "mrbgems/mruby-compiler/core/parse.y"
{
(yyval.nd) = 0;
}
-#line 10017 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 10012 "mrbgems/mruby-compiler/core/y.tab.c"
break;
-#line 10021 "mrbgems/mruby-compiler/core/y.tab.c"
+#line 10016 "mrbgems/mruby-compiler/core/y.tab.c"
default: break;
}
@@ -10249,7 +10244,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 4133 "mrbgems/mruby-compiler/core/parse.y"
+#line 4128 "mrbgems/mruby-compiler/core/parse.y"
#define pylval (*((YYSTYPE*)(p->ylval)))

MODIFY
src/kernel.c
src/kernel.c
@@ -612,6 +612,17 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self)
return mrb_false_value();
}
+static mrb_value
+mrb_encoding(mrb_state *mrb, mrb_value self)
+{
+ mrb_get_args(mrb, "");
+#ifdef MRB_UTF8_STRING
+ return mrb_str_new_lit(mrb, "UTF-8");
+#else
+ return mrb_str_new_lit(mrb, "ASCII-8BIT");
+#endif
+}
+
mrb_value mrb_obj_equal_m(mrb_state *mrb, mrb_value);
void
@@ -652,6 +663,7 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */
mrb_define_method(mrb, krn, "__case_eqq", mrb_obj_ceqq, MRB_ARGS_REQ(1)); /* internal */
mrb_define_method(mrb, krn, "__to_int", mrb_to_integer, MRB_ARGS_NONE()); /* internal */
+ mrb_define_method(mrb, krn, "__ENCODING__", mrb_encoding, MRB_ARGS_NONE());
mrb_include_module(mrb, mrb->object_class, mrb->kernel_module);
}

parse.y: `__ENCODING__` should be determined in run-time; fix #5552

It used to be compiled to the static string in the compiler. But the
encoding status actually depends on the runtime configuration. A new
method `Kernel#__ENCODING__` is introduced to implement the feature.