class Rattler::Compiler::Optimizer::JoinMatchMatchingSequence
Sequences of Regexp matches can be joined into a single Regexp without affecting how they match.
Protected Instance Methods
_applies_to?(parser, context)
click to toggle source
# File lib/rattler/compiler/optimizer/join_match_matching_sequence.rb, line 14 def _applies_to?(parser, context) context.matching? and parser.is_a?(Sequence) and any_neighbors?(parser) {|_| eligible_child? _ } end
create_pattern(match)
click to toggle source
# File lib/rattler/compiler/optimizer/join_match_matching_sequence.rb, line 24 def create_pattern(match) "(?>#{match.re.source})" end
eligible_child?(child)
click to toggle source
# File lib/rattler/compiler/optimizer/join_match_matching_sequence.rb, line 20 def eligible_child?(child) child.is_a? Match end