aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-25 13:51:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-25 13:52:53 +0900
commit33c5ad3154099769cec7f77b6d95cbf4b8d52bb0 (patch)
tree90034f953ef1914acbcb2b094c7b1fea48d1bd8f
parent55e1e22b2d44a8a1eca0f6ed2b11dc0f564f7192 (diff)
downloadruby-33c5ad3154099769cec7f77b6d95cbf4b8d52bb0.tar.gz
Removed idNUMPARAM_0
-rw-r--r--defs/id.def1
-rw-r--r--parse.y13
-rw-r--r--test/ripper/test_parser_events.rb1
3 files changed, 10 insertions, 5 deletions
diff --git a/defs/id.def b/defs/id.def
index f0e1db90dc..a35b5d55f9 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -60,7 +60,6 @@ firstline, predefined = __LINE__+1, %[\
_ UScore
# MUST be successive
- _0 NUMPARAM_0
_1 NUMPARAM_1
_2 NUMPARAM_2
_3 NUMPARAM_3
diff --git a/parse.y b/parse.y
index 48dd44a197..14568d98c3 100644
--- a/parse.y
+++ b/parse.y
@@ -173,9 +173,16 @@ enum {
NUMPARAM_MAX = 9,
};
-#define NUMPARAM_ID_P(id) (is_local_id(id) && NUMPARAM_ID_TO_IDX(id) <= NUMPARAM_MAX)
-#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_0)
-#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_0 + (idx)))
+#define NUMPARAM_ID_P(id) numparam_id_p(id)
+#define NUMPARAM_ID_TO_IDX(id) (unsigned int)(((id) >> ID_SCOPE_SHIFT) - tNUMPARAM_1 + 1)
+#define NUMPARAM_IDX_TO_ID(idx) TOKEN2LOCALID((tNUMPARAM_1 + (idx) - 1))
+static int
+numparam_id_p(ID id)
+{
+ if (!is_local_id(id)) return 0;
+ unsigned int idx = NUMPARAM_ID_TO_IDX(id);
+ return idx > 0 && idx <= NUMPARAM_MAX;
+}
#define DVARS_INHERIT ((void*)1)
#define DVARS_TOPSCOPE NULL
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 662ab3d7fe..4cb56f66f0 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -60,7 +60,6 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal '[ref(true)]', parse('true')
assert_equal '[vcall(_0)]', parse('_0')
assert_equal '[vcall(_1)]', parse('_1')
- assert_include parse('proc{_0}'), '[ref(_0)]'
assert_include parse('proc{_1}'), '[ref(_1)]'
end