From 72b785e07210c7419802caa3595fc03d84df2c3a Mon Sep 17 00:00:00 2001
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Thu, 5 Nov 2015 04:04:00 +0000
Subject: 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
---
 defs/id.def | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

(limited to 'defs/id.def')

diff --git a/defs/id.def b/defs/id.def
index f79e5ef4cf..d871200cf9 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,
 }
-- 
cgit v1.2.3

