summaryrefslogtreecommitdiff
path: root/defs
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:03 +0000
commit298694a2fdf4451163299d61a49a15fe49ab598a (patch)
treee58e7ee0155c1043c0da27a2e9c30699f8668a1c /defs
parente8794bf2151bf2427e9a69f86cd818c9ed24d0fa (diff)
id.def: other scope ID
* defs/id.def: support for other scope IDs, ID_{INSTANCE,GLOBAL,CONST,CLASS}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'defs')
-rw-r--r--defs/id.def34
1 files changed, 29 insertions, 5 deletions
diff --git a/defs/id.def b/defs/id.def
index 0c47bd7..a9b189f 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -1,5 +1,5 @@
-# -*- ruby -*-
-predefined = %[\
+# -*- mode: ruby; coding: us-ascii -*-
+firstline, predefined = __LINE__+1, %[\
intern
method_missing MethodMissing
length
@@ -35,16 +35,40 @@ predefined = %[\
predefined_ids = {}
preserved_ids = []
-attr_ids = []
-predefined.each_line do |line|
+local_ids = []
+instance_ids = []
+global_ids = []
+const_ids = []
+class_ids = []
+names = {}
+predefined.lines.each_with_index do |line, num|
next if /^#/ =~ line or (name, token = line.split; !name)
token ||= name
if /#/ =~ token
token = "_#{token.gsub(/\W+/, '_')}"
else
token = token.sub(/\?/, 'P').sub(/\A[a-z]/) {$&.upcase}
+ token.sub!(/\A\$/, "_G_")
+ token.sub!(/\A@@/, "_C_")
+ token.sub!(/\A@/, "_I_")
token.gsub!(/\W+/, "")
end
- (/\A(?!\d)\w+\z/ =~ name ? attr_ids : preserved_ids) << token
+ case name
+ when /\A[A-Z]\w*\z/; const_ids
+ when /\A(?!\d)\w+\z/; local_ids
+ when /\A\$(?:\d+|(?!\d)\w+)\z/; global_ids
+ when /\A@@(?!\d)\w+\z/; class_ids
+ when /\A@(?!\d)\w+\z/; instance_ids
+ else preserved_ids
+ end << token
predefined_ids[token] = name
end
+{
+ "LOCAL" => local_ids,
+ "INSTANCE" => instance_ids,
+ "GLOBAL" => global_ids,
+ "CONST" => const_ids,
+ "CLASS" => class_ids,
+ :preserved => preserved_ids,
+ :predefined => predefined_ids,
+}