summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-11 16:21:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-11 16:21:33 +0000
commita55c6429b99d11f480471a2b0f1cd9a67e3034b6 (patch)
tree9571a907abec8aff63c25cb20745710a3bdd6ce3 /parse.y
parent6b957b3ff5bb4bf0d7afdf3ec15e477bc7567aaf (diff)
* eval.c (rb_eval), parse.y (arg): reduce fixnum range literal at
parser. fixed: [ruby-dev:26113] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y18
1 files changed, 16 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 2b41cd5..fe2cd06 100644
--- a/parse.y
+++ b/parse.y
@@ -1057,13 +1057,27 @@ arg : lhs '=' arg
{
value_expr($1);
value_expr($3);
- $$ = NEW_DOT2($1, $3);
+ if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
+ nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
+ $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qfalse);
+ $$ = $1;
+ }
+ else {
+ $$ = NEW_DOT2($1, $3);
+ }
}
| arg tDOT3 arg
{
value_expr($1);
value_expr($3);
- $$ = NEW_DOT3($1, $3);
+ if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) &&
+ nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) {
+ $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qtrue);
+ $$ = $1;
+ }
+ else {
+ $$ = NEW_DOT3($1, $3);
+ }
}
| arg '+' arg
{