Class: ZeroOrMoreOfPattern

Inherits:
RepeatablePattern show all
Defined in:
lib/ruby_grammar_builder/pattern_extensions/zero_or_more_of.rb

Overview

An repeated pattern for some pattern ‘p` this is equivalent to (?:p*)

Instance Attribute Summary

Attributes inherited from RepeatablePattern

#at_least, #at_most

Attributes inherited from PatternBase

#arguments, #match, #next_pattern, #original_arguments

Instance Method Summary collapse

Methods inherited from RepeatablePattern

#add_quantifier_options_to, #do_add_attributes, #do_evaluate_self, #process_quantifiers_from_arguments, #self_capture_group_rematch, #simple_quantifier

Methods inherited from PatternBase

#==, #__deep_clone__, #__deep_clone_self__, #collect_group_attributes, #convert_group_attributes_to_captures, #convert_includes_to_patterns, #do_add_attributes, #do_collect_self_groups, #do_evaluate_self, #each, #eql?, #evaluate, #evaluate_operator, #fixup_regex_references, #groupless, #groupless?, #hash, #insert, #insert!, #inspect, #lookAheadFor, #lookAheadToAvoid, #lookAround, #lookBehindFor, #lookBehindToAvoid, #map, #map!, #map_includes!, #matchResultOf, #maybe, #name, #needs_to_capture?, #oneOf, #oneOrMoreOf, #optimize_outer_group?, #or, #placeholder, #raise_if_regex_has_capture_group, #reTag, #recursivelyMatch, #resolve, #run_self_tests, #run_tests, #self_scramble_references, #single_entity?, #start_pattern, #then, #to_r, #to_s, #to_tag, #transform_includes, #transform_tag_as, #zeroOrMoreOf

Constructor Details

#initialize(*args) ⇒ ZeroOrMoreOfPattern

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Construct a new ZeroOrMoreOfPattern

Parameters:

See Also:



14
15
16
17
18
19
20
# File 'lib/ruby_grammar_builder/pattern_extensions/zero_or_more_of.rb', line 14

def initialize(*args)
    # run the normal pattern
    super(*args)
    # add quantifying options
    @at_least = 0
    @at_most = nil
end

Instance Method Details

#do_get_to_s_name(top_level) ⇒ String

What is the name of the method that the user would call top_level is if a freestanding or chaining function is called called by #to_s

Parameters:

  • top_level (Boolean)

    is this top_level or chained

Returns:

  • (String)

    the name of the method



29
30
31
# File 'lib/ruby_grammar_builder/pattern_extensions/zero_or_more_of.rb', line 29

def do_get_to_s_name(top_level)
    top_level ? "zeroOrMoreOf(" : ".zeroOrMoreOf("
end

#quantifying_allowed?Boolean, false

Note:

override when inheriting. Return false unless the subclass allow quantifying

Note:

the default implementation returns True

controls weather @arguments et. al. set @at_most et. al.

Returns:

  • (Boolean)

    if quantifying is allowed

  • (false)


24
25
26
# File 'lib/ruby_grammar_builder/pattern_extensions/zero_or_more_of.rb', line 24

def quantifying_allowed?
    false
end