From 298694a2fdf4451163299d61a49a15fe49ab598a Mon Sep 17 00:00:00 2001
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Fri, 21 Dec 2012 07:38:03 +0000
Subject: 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
---
 defs/id.def | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

(limited to 'defs/id.def')

diff --git a/defs/id.def b/defs/id.def
index 0c47bd7804..a9b189f5aa 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,
+}
-- 
cgit v1.2.3

