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