summaryrefslogtreecommitdiff
path: root/defs
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-05 04:04:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-05 04:04:00 +0000
commit72b785e07210c7419802caa3595fc03d84df2c3a (patch)
tree618b9df3d58a48193bba18ccbc56819b41c900b4 /defs
parentfcd15352327bb7d6c8db952e8c3fb3ce7412cca1 (diff)
id.def: token_ops
* defs/id.def (token_ops): gather associations between IDs, operators, and parser tokens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'defs')
-rw-r--r--defs/id.def46
1 files changed, 46 insertions, 0 deletions
diff --git a/defs/id.def b/defs/id.def
index f79e5ef..d871200 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -65,6 +65,42 @@ firstline, predefined = __LINE__+1, %[\
- debug#created_line
]
+# VM ID OP Parser Token
+token_ops = %[\
+ Dot2 .. DOT2
+ Dot3 ... DOT3
+ UPlus +@ UPLUS
+ UMinus -@ UMINUS
+ Pow ** POW
+ DSTAR **
+ Cmp <=> CMP
+ PLUS +
+ MINUS -
+ MULT *
+ DIV /
+ MOD %
+ LTLT << LSHFT
+ GTGT >> RSHFT
+ LT <
+ LE <= LEQ
+ GT >
+ GE >= GEQ
+ Eq == EQ
+ Eqq === EQQ
+ Neq != NEQ
+ Not !
+ Backquote `
+ EqTilde =~ MATCH
+ NeqTilde !~ NMATCH
+ AREF []
+ ASET []=
+ COLON2 ::
+ COLON3 ::
+ ANDOP &&
+ OROP ||
+ DOTQ .?
+]
+
class KeywordError < RuntimeError
def self.raise(mesg, line)
super(self, mesg, ["#{__FILE__}:#{line}", *caller])
@@ -79,6 +115,7 @@ global_ids = []
const_ids = []
class_ids = []
attrset_ids = []
+token_op_ids = []
names = {}
predefined.split(/^/).each_with_index do |line, num|
next if /^#/ =~ line
@@ -117,6 +154,14 @@ predefined.split(/^/).each_with_index do |line, num|
end << token
predefined_ids[token] = name
end
+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]
+end
{
"LOCAL" => local_ids,
"INSTANCE" => instance_ids,
@@ -126,4 +171,5 @@ end
"ATTRSET" => attrset_ids,
:preserved => preserved_ids,
:predefined => predefined_ids,
+ :token_op => token_op_ids,
}