2012-12-21 02:38:03 -05:00
|
|
|
# -*- mode: ruby; coding: us-ascii -*-
|
|
|
|
firstline, predefined = __LINE__+1, %[\
|
2013-11-09 16:17:06 -05:00
|
|
|
freeze
|
2013-05-02 03:54:17 -04:00
|
|
|
inspect
|
2012-12-04 12:36:19 -05:00
|
|
|
intern
|
2013-05-02 03:54:17 -04:00
|
|
|
object_id
|
|
|
|
const_missing
|
2012-12-04 12:36:19 -05:00
|
|
|
method_missing MethodMissing
|
2013-05-02 03:54:17 -04:00
|
|
|
method_added
|
|
|
|
singleton_method_added
|
|
|
|
method_removed
|
|
|
|
singleton_method_removed
|
|
|
|
method_undefined
|
|
|
|
singleton_method_undefined
|
2012-12-04 12:36:19 -05:00
|
|
|
length
|
|
|
|
size
|
|
|
|
gets
|
|
|
|
succ
|
|
|
|
each
|
2013-04-30 22:38:44 -04:00
|
|
|
proc
|
2012-12-04 12:36:19 -05:00
|
|
|
lambda
|
|
|
|
send
|
|
|
|
__send__
|
2013-05-02 03:54:17 -04:00
|
|
|
__attached__
|
2012-12-04 12:36:19 -05:00
|
|
|
initialize
|
|
|
|
initialize_copy
|
|
|
|
initialize_clone
|
|
|
|
initialize_dup
|
2014-05-20 02:28:52 -04:00
|
|
|
to_int
|
|
|
|
to_ary
|
|
|
|
to_str
|
|
|
|
to_sym
|
|
|
|
to_hash
|
|
|
|
to_proc
|
|
|
|
to_io
|
|
|
|
to_a
|
|
|
|
to_s
|
2014-05-20 04:28:33 -04:00
|
|
|
to_i
|
2014-06-28 00:58:25 -04:00
|
|
|
bt
|
|
|
|
bt_locations
|
2014-05-20 02:28:52 -04:00
|
|
|
|
2012-12-04 12:36:19 -05:00
|
|
|
_ UScore
|
|
|
|
"/*NULL*/" NULL
|
|
|
|
empty?
|
2013-05-02 03:54:17 -04:00
|
|
|
eql?
|
2012-12-04 12:36:19 -05:00
|
|
|
respond_to? Respond_to
|
|
|
|
respond_to_missing? Respond_to_missing
|
|
|
|
<IFUNC>
|
|
|
|
<CFUNC>
|
|
|
|
core#set_method_alias
|
|
|
|
core#set_variable_alias
|
|
|
|
core#undef_method
|
|
|
|
core#define_method
|
|
|
|
core#define_singleton_method
|
|
|
|
core#set_postexe
|
|
|
|
core#hash_from_ary
|
|
|
|
core#hash_merge_ary
|
|
|
|
core#hash_merge_ptr
|
|
|
|
core#hash_merge_kwd
|
|
|
|
]
|
|
|
|
|
2012-12-21 02:38:07 -05:00
|
|
|
class KeywordError < RuntimeError
|
|
|
|
def self.raise(mesg, line)
|
|
|
|
super(self, mesg, ["#{__FILE__}:#{line}", *caller])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-04 12:36:19 -05:00
|
|
|
predefined_ids = {}
|
|
|
|
preserved_ids = []
|
2012-12-21 02:38:03 -05:00
|
|
|
local_ids = []
|
|
|
|
instance_ids = []
|
|
|
|
global_ids = []
|
|
|
|
const_ids = []
|
|
|
|
class_ids = []
|
|
|
|
names = {}
|
2012-12-27 17:08:41 -05:00
|
|
|
predefined.split(/^/).each_with_index do |line, num|
|
2013-04-30 22:38:44 -04:00
|
|
|
next if /^#/ =~ line
|
|
|
|
line.sub!(/\s+#.*/, '')
|
|
|
|
name, token = line.split
|
|
|
|
next unless name
|
2012-12-04 12:36:19 -05:00
|
|
|
token ||= name
|
|
|
|
if /#/ =~ token
|
|
|
|
token = "_#{token.gsub(/\W+/, '_')}"
|
|
|
|
else
|
|
|
|
token = token.sub(/\?/, 'P').sub(/\A[a-z]/) {$&.upcase}
|
2012-12-21 02:38:03 -05:00
|
|
|
token.sub!(/\A\$/, "_G_")
|
|
|
|
token.sub!(/\A@@/, "_C_")
|
|
|
|
token.sub!(/\A@/, "_I_")
|
2012-12-04 12:36:19 -05:00
|
|
|
token.gsub!(/\W+/, "")
|
|
|
|
end
|
2012-12-21 02:38:07 -05:00
|
|
|
if prev = names[name]
|
|
|
|
KeywordError.raise("#{name} is already registered at line #{prev+firstline}", firstline+num)
|
|
|
|
end
|
|
|
|
if prev = predefined_ids[token]
|
|
|
|
KeywordError.raise("#{token} is already used for #{prev} at line #{names[prev]+firstline}", firstline+num)
|
|
|
|
end
|
|
|
|
names[name] = num
|
2012-12-21 02:38:03 -05:00
|
|
|
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
|
2012-12-21 02:38:11 -05:00
|
|
|
when /\A((?!\d)\w+)=\z/
|
|
|
|
KeywordError.raise("use ID2ATTRSET(#{$1}) instead of ATTRSET #{name}", firstline+num)
|
2012-12-21 02:38:03 -05:00
|
|
|
else preserved_ids
|
|
|
|
end << token
|
2012-12-04 12:36:19 -05:00
|
|
|
predefined_ids[token] = name
|
|
|
|
end
|
2012-12-21 02:38:03 -05:00
|
|
|
{
|
|
|
|
"LOCAL" => local_ids,
|
|
|
|
"INSTANCE" => instance_ids,
|
|
|
|
"GLOBAL" => global_ids,
|
|
|
|
"CONST" => const_ids,
|
|
|
|
"CLASS" => class_ids,
|
|
|
|
:preserved => preserved_ids,
|
|
|
|
:predefined => predefined_ids,
|
|
|
|
}
|