2012-08-31 09:31:20 +04:00
|
|
|
#! /usr/bin/ruby -p
|
2012-11-29 12:12:29 +04:00
|
|
|
# -*- coding: us-ascii -*-
|
2016-07-03 00:01:04 +03:00
|
|
|
|
|
|
|
# Used to build the Ruby parsing code in common.mk and Ripper.
|
|
|
|
|
2012-08-31 09:31:20 +04:00
|
|
|
BEGIN {
|
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
opt = OptionParser.new do |o|
|
2022-09-08 09:36:04 +03:00
|
|
|
o.order!(ARGV)
|
2012-08-31 09:31:20 +04:00
|
|
|
end or abort opt.opt_s
|
|
|
|
|
|
|
|
TOKENS = {}
|
2022-09-08 09:36:04 +03:00
|
|
|
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|
|
2012-11-29 12:12:29 +04:00
|
|
|
TOKENS[token] = id
|
|
|
|
end
|
2012-08-31 09:31:20 +04:00
|
|
|
|
|
|
|
TOKENS_RE = /\bRUBY_TOKEN\((#{TOKENS.keys.join('|')})\)\s*(?=\s)/
|
|
|
|
}
|
|
|
|
|
|
|
|
$_.gsub!(TOKENS_RE) {TOKENS[$1]} if /^%token/ =~ $_
|