class LookAroundPattern
Implements lookarounds for some pattern p this is equivalent to one of /(?=p)/, /(?!p)/, /(?<p)/, /(?<!p)/ depending on the type
Public Instance Methods
do_add_attributes(indent)
click to toggle source
(see PatternBase#do_add_attributes
)
# File lib/ruby_grammar_builder/pattern_extensions/lookaround_pattern.rb, line 34 def do_add_attributes(indent) ",\n#{indent} type: :#{@arguments[:type]}" end
do_evaluate_self(groups)
click to toggle source
(see PatternBase#do_evaluate_self
)
# File lib/ruby_grammar_builder/pattern_extensions/lookaround_pattern.rb, line 10 def do_evaluate_self(groups) self_regex = @match self_regex = @match.evaluate(groups) if @match.is_a? PatternBase case @arguments[:type] when :lookAheadFor then self_regex = "(?=#{self_regex})" when :lookAheadToAvoid then self_regex = "(?!#{self_regex})" when :lookBehindFor then self_regex = "(?<=#{self_regex})" when :lookBehindToAvoid then self_regex = "(?<!#{self_regex})" end if needs_to_capture? raise "You cannot capture a lookAround\nconsider capturing the pattern inside" end self_regex end
do_get_to_s_name(top_level)
click to toggle source
(see PatternBase#do_get_to_s_name
)
# File lib/ruby_grammar_builder/pattern_extensions/lookaround_pattern.rb, line 29 def do_get_to_s_name(top_level) top_level ? "lookAround(" : ".lookAround(" end
single_entity?()
click to toggle source
(see PatternBase#single_entity?
) @return [true]
# File lib/ruby_grammar_builder/pattern_extensions/lookaround_pattern.rb, line 40 def single_entity? true end