summaryrefslogtreecommitdiff
path: root/defs
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-21 07:38:07 +0000
commit2edcf87c1c30c29562fc52075896935ebf398367 (patch)
treeebe3d9efe134d0da8799fa2bc46b304879684526 /defs
parent298694a2fdf4451163299d61a49a15fe49ab598a (diff)
id.def: check duplication
* defs/id.def (KeywordError): check duplication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'defs')
-rw-r--r--defs/id.def13
1 files changed, 13 insertions, 0 deletions
diff --git a/defs/id.def b/defs/id.def
index a9b189f..48c6334 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -33,6 +33,12 @@ firstline, predefined = __LINE__+1, %[\
core#hash_merge_kwd
]
+class KeywordError < RuntimeError
+ def self.raise(mesg, line)
+ super(self, mesg, ["#{__FILE__}:#{line}", *caller])
+ end
+end
+
predefined_ids = {}
preserved_ids = []
local_ids = []
@@ -53,6 +59,13 @@ predefined.lines.each_with_index do |line, num|
token.sub!(/\A@/, "_I_")
token.gsub!(/\W+/, "")
end
+ if prev = names[name]
+ KeywordError.raise("#{name} is already registered at line #{prev+firstline}", firstline+num)
+ end
+ if prev = predefined_ids[token]
+ KeywordError.raise("#{token} is already used for #{prev} at line #{names[prev]+firstline}", firstline+num)
+ end
+ names[name] = num
case name
when /\A[A-Z]\w*\z/; const_ids
when /\A(?!\d)\w+\z/; local_ids