diff --git a/defs/id.def b/defs/id.def index 097e34e405..94af02b12f 100644 --- a/defs/id.def +++ b/defs/id.def @@ -194,13 +194,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, @@ -212,4 +213,5 @@ end :preserved => preserved_ids, :predefined => predefined_ids, :token_op => token_op_ids, + :last_token => index, } diff --git a/template/id.c.tmpl b/template/id.c.tmpl index 4f30875c04..5b9e879730 100644 --- a/template/id.c.tmpl +++ b/template/id.c.tmpl @@ -12,7 +12,7 @@ **********************************************************************/ <% defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def") -ids = eval(File.read(defs), binding, defs) +ids = eval(File.read(defs), nil, defs) ops = ids[:token_op].uniq {|id, op, token| token && op} %> % ops.each do |_id, _op, token| diff --git a/template/id.h.tmpl b/template/id.h.tmpl index 687cbbbe40..9c588305eb 100644 --- a/template/id.h.tmpl +++ b/template/id.h.tmpl @@ -11,10 +11,8 @@ **********************************************************************/ <% -op_id_offset = 128 - defs = File.join(File.dirname(File.dirname(erb.filename)), "defs/id.def") -ids = eval(File.read(defs), binding, defs) +ids = eval(File.read(defs), nil, defs) types = ids.keys.grep(/^[A-Z]/) %> #ifndef RUBY_ID_H @@ -49,11 +47,9 @@ enum ruby_id_types { #define symIFUNC ID2SYM(idIFUNC) #define symCFUNC ID2SYM(idCFUNC) -% index = op_id_offset -% ids[:token_op].each do |_id, _op, token| +% ids[:token_op].each do |_id, _op, token, index| % next unless token #define RUBY_TOKEN_<%=token%> <%=index%> -% index += 1 % end #define RUBY_TOKEN(t) RUBY_TOKEN_##t @@ -66,7 +62,7 @@ enum ruby_method_ids { % ids[:token_op].uniq {|_, op| op}.each do |id, op, token| id<%=id%> = <%=token ? "RUBY_TOKEN(#{token})" : "'#{op}'"%>, % end - tPRESERVED_ID_BEGIN = <%=index-1%>, + tPRESERVED_ID_BEGIN = <%=ids[:last_token]%>, % ids[:preserved].each do |token| id<%=token%>, % end