summaryrefslogtreecommitdiff
path: root/defs/id.def
blob: 0c47bd78047d6306abf5be3c56ecaa473f0e14d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- ruby -*-
predefined = %[\
  intern
  method_missing                                        MethodMissing
  length
  size
  gets
  succ
  each
  lambda
  send
  __send__
  initialize
  initialize_copy
  initialize_clone
  initialize_dup
  _                                                     UScore
  "/*NULL*/"                                            NULL
  empty?
  respond_to?                                           Respond_to
  respond_to_missing?                                   Respond_to_missing
  <IFUNC>
  <CFUNC>
  core#set_method_alias
  core#set_variable_alias
  core#undef_method
  core#define_method
  core#define_singleton_method
  core#set_postexe
  core#hash_from_ary
  core#hash_merge_ary
  core#hash_merge_ptr
  core#hash_merge_kwd
]

predefined_ids = {}
preserved_ids = []
attr_ids = []
predefined.each_line do |line|
  next if /^#/ =~ line or (name, token = line.split; !name)
  token ||= name
  if /#/ =~ token
    token = "_#{token.gsub(/\W+/, '_')}"
  else
    token = token.sub(/\?/, 'P').sub(/\A[a-z]/) {$&.upcase}
    token.gsub!(/\W+/, "")
  end
  (/\A(?!\d)\w+\z/ =~ name ? attr_ids : preserved_ids) << token
  predefined_ids[token] = name
end