class RecursivelyMatchPattern
Implements subexp calls for some group N whose reference is “foo” recursivelyMatch(“foo”) results in the pattern /gN/
Public Class Methods
new(reference, deep_clone = nil, original_arguments = nil)
click to toggle source
Calls superclass method
PatternBase::new
# File lib/textmate_grammar/pattern_extensions/recursively_match.rb, line 9 def initialize(reference, deep_clone = nil, original_arguments = nil) if reference.is_a? String super( match: Regexp.new("(?#[:subroutine:#{reference}:])"), subroutine_key: reference ) else # most likely __deep_clone__ was called, just call the super initializer super(reference, deep_clone, original_arguments) end end
Public Instance Methods
self_capture_group_rematch()
click to toggle source
RecursivelyMatchPattern
can cause its capture groups to be rematched
@return [true] rematching is possible
# File lib/textmate_grammar/pattern_extensions/recursively_match.rb, line 55 def self_capture_group_rematch true end
self_scramble_references()
click to toggle source
(see PatternBase#self_scramble_references
)
# File lib/textmate_grammar/pattern_extensions/recursively_match.rb, line 36 def self_scramble_references scramble = lambda do |name| return name if name.start_with?("__scrambled__") "__scrambled__" + name end key = @arguments[:subroutine_key] scrambled = scramble.call(key) @match = @match.sub(key, scrambled) @arguments[:subroutine_key] = scrambled end
single_entity?()
click to toggle source
(see PatternBase#single_entity?
) @return [true]
# File lib/textmate_grammar/pattern_extensions/recursively_match.rb, line 31 def single_entity? true end
to_s(depth = 0, top_level = true)
click to toggle source
(see PatternBase#to_s
)
# File lib/textmate_grammar/pattern_extensions/recursively_match.rb, line 22 def to_s(depth = 0, top_level = true) output = top_level ? "recursivelyMatch(" : ".recursivelyMatch(" output += "\"#{@arguments[:subroutine_key]}\")" output += @next_pattern.to_s(depth, false).lstrip if @next_pattern output end