diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-09-08 15:36:04 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-09-08 18:22:47 +0900 |
commit | bcf82b7c26a88a2521715a38990f0ab081001190 (patch) | |
tree | 34d8f2a9b97797f5be2eb3dfbb89affbe84967c6 /tool/id2token.rb | |
parent | a977c663123f7256f51201ed8390dc84adf63cf6 (diff) | |
download | ruby-bcf82b7c26a88a2521715a38990f0ab081001190.tar.gz |
Process token IDs from id.def without id.h
Fixes id.h error during updating ripper.c by `make after-update`.
While it used to update id.h in the build directory, but was trying to
update ripper.c in the source directory. In principle, files in the
source directory can or should not depend on files in the build
directory.
Diffstat (limited to 'tool/id2token.rb')
-rwxr-xr-x | tool/id2token.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tool/id2token.rb b/tool/id2token.rb index d12ea9c08e..cf73095842 100755 --- a/tool/id2token.rb +++ b/tool/id2token.rb @@ -5,18 +5,15 @@ BEGIN { require 'optparse' - require_relative 'lib/vpath' - vpath = VPath.new - header = nil opt = OptionParser.new do |o| - vpath.def_options(o) - header = o.order!(ARGV).shift + o.order!(ARGV) end or abort opt.opt_s TOKENS = {} - h = vpath.read(header) rescue abort("#{header} not found in #{vpath.inspect}") - h.scan(/^#define\s+RUBY_TOKEN_(\w+)\s+(\d+)/) do |token, id| + defs = File.join(File.dirname(File.dirname(__FILE__)), "defs/id.def") + ids = eval(File.read(defs), nil, defs) + ids[:token_op].each do |_id, _op, token, id| TOKENS[token] = id end |