Create  Edit  Diff  Phillro Industries  Index  Search  Changes  History  Source  RSS  Note  wikifarm  Login

enums_in_delphi_source.rb

   1|#-- enums_in_delphi_source.rb
   2|#
   3|# => enums_in_delphi_source_result.rb
   4|#
   5|delphi_source_dir = "C:/Program Files/Borland/Delphi6/Source/"
   6|files = Dir.glob(delphi_source_dir+"**/*.pas")
   7|files.each{|path|
   8|  text = open(path).read
   9|  parts = []
  10|  parts  = text.scan(/^\s*T\w*\s*\=\s*\(.*?\)/m)
  11|  parts += text.scan(/^\s*type\w+T\w*\s*\=\s*\(.*?\)/mi)
  12|  parts += text.scan(/^\s*T\w*\s*\=\s*set\s+of\s*\(.*?\)/mi)
  13|  if !parts.empty?
  14|    parts = parts.collect{|part| 
  15|      part.to_a.collect{|line|
  16|        case line
  17|        when /(.*?)\/\// ; line = $1
  18|        when /(.*?)\{/ ; line = $1
  19|        # ommit like TOKEN_READ = (STANDARD_RIGHTS_READ or TOKEN_QUERY)
  20|        when / or / ; next
  21|        # ommit like TA_MASK =  (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)
  22|        when /\+/ ; next
  23|        end
  24|        line.strip
  25|      }.compact.join(' ')
  26|    }
  27|    puts "#-- "+path
  28|    puts parts
  29|  end
  30|}
  31|p :end
  32|
  33|
Last modified:2004/11/09 15:54:06
Keyword(s):
References:[SupportScripts] [enums_in_delphi_source_result.rb]