diff options
Diffstat (limited to 'defs/id.def')
| -rw-r--r-- | defs/id.def | 77 |
1 files changed, 63 insertions, 14 deletions
diff --git a/defs/id.def b/defs/id.def index f30b993bd9..344b072e76 100644 --- a/defs/id.def +++ b/defs/id.def @@ -2,10 +2,14 @@ firstline, predefined = __LINE__+1, %[\ max min + hash freeze + nil? inspect intern object_id + __id__ + const_added const_missing method_missing MethodMissing method_added @@ -23,7 +27,8 @@ firstline, predefined = __LINE__+1, %[\ lambda send __send__ - __attached__ + __recursive_key__ + clone initialize initialize_copy initialize_clone @@ -38,20 +43,49 @@ firstline, predefined = __LINE__+1, %[\ to_a to_s to_i + to_f to_r bt bt_locations call mesg exception + locals not NOT and AND or OR + div + divmod + fdiv + quo + name + nil + path + pack + buffer + include? + aborted + exited _ UScore + + # MUST be successive + _1 NUMPARAM_1 + _2 NUMPARAM_2 + _3 NUMPARAM_3 + _4 NUMPARAM_4 + _5 NUMPARAM_5 + _6 NUMPARAM_6 + _7 NUMPARAM_7 + _8 NUMPARAM_8 + _9 NUMPARAM_9 + <it> ItImplicit + it It + "/*NULL*/" NULL empty? eql? + default respond_to? Respond_to respond_to_missing? Respond_to_missing <IFUNC> @@ -62,21 +96,26 @@ firstline, predefined = __LINE__+1, %[\ 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 + core#raise + core#sprintf - debug#created_info $_ LASTLINE $~ BACKREF + $! ERROR_INFO + + Ruby ] # VM ID OP Parser Token token_ops = %[\ Dot2 .. DOT2 Dot3 ... DOT3 + BDot2 .. BDOT2 + BDot3 ... BDOT3 UPlus +@ UPLUS UMinus -@ UMINUS Pow ** POW @@ -96,6 +135,8 @@ token_ops = %[\ Eqq === EQQ Neq != NEQ Not ! + And & + Or | Backquote ` EqTilde =~ MATCH NeqTilde !~ NMATCH @@ -113,6 +154,21 @@ class KeywordError < RuntimeError end end +def id2varname(token, prefix = nil) + if /#/ =~ token + token = "_#{token.gsub(/\W+/, '_')}" + else + token = token.sub(/\?/, 'P') + token = prefix + token if prefix + token.sub!(/\A[a-z]/) {$&.upcase} + token.sub!(/\A\$/, "_G_") + token.sub!(/\A@@/, "_C_") + token.sub!(/\A@/, "_I_") + token.gsub!(/\W+/, "") + end + token +end + predefined_ids = {} preserved_ids = [] local_ids = [] @@ -128,16 +184,7 @@ predefined.split(/^/).each_with_index do |line, num| line.sub!(/\s+#.*/, '') name, token = line.split next unless 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 + token = id2varname(token || name) if name == '-' preserved_ids << token next @@ -160,13 +207,14 @@ predefined.split(/^/).each_with_index do |line, num| end << token predefined_ids[token] = name end +index = 127 token_ops.split(/^/).each do |line| next if /^#/ =~ line line.sub!(/\s+#.*/, '') id, op, token = line.split next unless id and op token ||= (id unless /\A\W\z/ =~ op) - token_op_ids << [id, op, token] + token_op_ids << [id, op, token, (index += 1 if token)] end { "LOCAL" => local_ids, @@ -178,4 +226,5 @@ end :preserved => preserved_ids, :predefined => predefined_ids, :token_op => token_op_ids, + :last_token => index, } |
