lib/regextest/front/letter.rb in regextest-0.1.4 vs lib/regextest/front/letter.rb in regextest-0.1.5
- old
+ new
@@ -4,11 +4,10 @@
require 'regextest/common'
require 'regextest/front/char-class' # character class element
require 'regextest/front/range' # range of character point
require 'regextest/regex-option'
-require 'regextest/front/unicode'
# A letter
module Regextest::Front::Letter
class TLetter
include Regextest::Common
@@ -177,38 +176,24 @@
obj
end
# generate Unicode class (ie. \p{...} | \P{...})
def generate_unicode_char(val)
- # Dynamic loading of Unicode regarding modules (for better performance).
- # commented out since this code not executed at ruby 2.0.0
- # require 'regextest/front/unicode'
-
if(md = val.match(/(p|P)\{(\^?)(\w+)\}/))
class_name = md[3].downcase
reverse = (md[2] && md[2]=="^")?true:false
- # if not found at cache
- if !@@unicode_ranges[class_name]
- #work = Regextest::Front::Unicode.property(class_name) ||
- # raise("Invalid Unicode class #{class_name} in #{val}")
- # construct char class
- #work = work.map{|elem| TRange.new(elem[0], elem[1])}
- @@unicode_ranges[class_name] = CharClass.new(class_name)
- end
+ obj = CharClass.new(class_name)
else
raise "Internal error, inconsistent Unicode class #{val}"
end
# ¥P{^...} is equivalent to \p{...}
if((md[1] == "p" && !reverse) || (md[1] == "P" && reverse))
- @@unicode_ranges[class_name]
+ obj
else # \P{} or \p{^}
- @@unicode_ranges[class_name].set_reverse(@options)
+ obj.set_reverse(@options)
end
- end
-
- def classname_to_ranges(arrays)
end
# generate POSIX character class (ie. [[:alpha:]], etc.)
def generate_char_class(val)
if(md = val.match(/^\[\:(\^)?(\w+)\:\]$/))