diff options
Diffstat (limited to 'defs')
-rw-r--r-- | defs/id.def | 34 |
1 files changed, 29 insertions, 5 deletions
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, +} |