2008-10-19 16:12:53 +04:00
|
|
|
%# -*- c -*-
|
|
|
|
/* DO NOT EDIT THIS FILE DIRECTLY */
|
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
id.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sun Oct 19 21:12:51 2008
|
|
|
|
|
|
|
|
Copyright (C) 2007 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
<%
|
|
|
|
require 'optparse'
|
|
|
|
vpath = ["."]
|
|
|
|
input = nil
|
|
|
|
opt = OptionParser.new do |o|
|
|
|
|
o.on('-v', '--vpath=DIR') {|dirs| vpath.concat dirs.split(File::PATH_SEPARATOR)}
|
|
|
|
input, = o.order!(ARGV)
|
|
|
|
end or abort opt.opt_s
|
|
|
|
|
|
|
|
tokens = nil
|
|
|
|
vpath.find do |dir|
|
|
|
|
begin
|
|
|
|
if line = File.read(File.join(dir, input))[/^\s*enum\s+yytokentype\s*\{([^{}]*)\s*\};/m, 1]
|
|
|
|
tokens = line.scan(/\b(t(?:LAST_TOKEN|U(?:PLUS|MINUS)|POW|CMP|EQQ?|[NGL]EQ|(?:AND|OR)OP|N?MATCH|DOT\d|AREF|ASET|[LR]SHFT|LAMBDA)|id\w+)\s*=\s*(\d+),?/m)
|
|
|
|
end
|
|
|
|
rescue Errno::ENOENT
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
%>
|
|
|
|
#ifndef RUBY_ID_H
|
|
|
|
#define RUBY_ID_H
|
|
|
|
|
|
|
|
#define ID_SCOPE_SHIFT 3
|
|
|
|
#define ID_SCOPE_MASK 0x07
|
|
|
|
#define ID_LOCAL 0x00
|
|
|
|
#define ID_INSTANCE 0x01
|
|
|
|
#define ID_GLOBAL 0x03
|
|
|
|
#define ID_ATTRSET 0x04
|
|
|
|
#define ID_CONST 0x05
|
|
|
|
#define ID_CLASS 0x06
|
|
|
|
#define ID_JUNK 0x07
|
|
|
|
#define ID_INTERNAL ID_JUNK
|
|
|
|
|
|
|
|
#ifdef USE_PARSE_H
|
|
|
|
#include "parse.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define symIFUNC ID2SYM(idIFUNC)
|
|
|
|
#define symCFUNC ID2SYM(idCFUNC)
|
|
|
|
|
|
|
|
enum ruby_method_ids {
|
|
|
|
#ifndef tLAST_TOKEN
|
|
|
|
% tokens.each do |token, value|
|
|
|
|
<%=token%> = <%=value%>,
|
|
|
|
% end
|
|
|
|
% tokens.map do |token, value|
|
|
|
|
#elif <%=token%> != <%=value%>
|
|
|
|
#error <%=token%> differs
|
|
|
|
% end
|
|
|
|
#endif
|
|
|
|
idPLUS = '+',
|
|
|
|
idMINUS = '-',
|
|
|
|
idMULT = '*',
|
|
|
|
idDIV = '/',
|
|
|
|
idMOD = '%',
|
|
|
|
idLT = '<',
|
|
|
|
idLTLT = tLSHFT,
|
|
|
|
idLE = tLEQ,
|
|
|
|
idGT = '>',
|
|
|
|
idGE = tGEQ,
|
|
|
|
idEq = tEQ,
|
|
|
|
idEqq = tEQQ,
|
|
|
|
idNeq = tNEQ,
|
|
|
|
idNot = '!',
|
|
|
|
idBackquote = '`',
|
|
|
|
idEqTilde = tMATCH,
|
|
|
|
idAREF = tAREF,
|
|
|
|
idASET = tASET,
|
|
|
|
idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
|
|
|
|
tIntern,
|
|
|
|
tMethodMissing,
|
|
|
|
tLength,
|
|
|
|
tGets,
|
|
|
|
tSucc,
|
|
|
|
tEach,
|
|
|
|
tLambda,
|
|
|
|
tSend,
|
|
|
|
t__send__,
|
|
|
|
tInitialize,
|
|
|
|
#if SUPPORT_JOKE
|
|
|
|
tBitblt,
|
|
|
|
tAnswer,
|
|
|
|
#endif
|
|
|
|
tLAST_ID,
|
|
|
|
#define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
|
2008-10-24 16:50:35 +04:00
|
|
|
#if SUPPORT_JOKE
|
|
|
|
TOKEN2ID(Bitblt),
|
|
|
|
TOKEN2ID(Answer),
|
|
|
|
#endif
|
2008-10-19 16:12:53 +04:00
|
|
|
TOKEN2ID(Intern),
|
|
|
|
TOKEN2ID(MethodMissing),
|
|
|
|
TOKEN2ID(Length),
|
|
|
|
TOKEN2ID(Gets),
|
|
|
|
TOKEN2ID(Succ),
|
|
|
|
TOKEN2ID(Each),
|
|
|
|
TOKEN2ID(Lambda),
|
|
|
|
TOKEN2ID(Send),
|
|
|
|
TOKEN2ID(__send__),
|
2008-10-24 16:50:35 +04:00
|
|
|
TOKEN2ID(Initialize)
|
2008-10-19 16:12:53 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* RUBY_ID_H */
|