class Pegmatite::Pattern::Repeat

Overview

Pattern::Repeat is used to specify a pattern that can or must repeat for a specified minimum number of occurrences.

When the child pattern eventually fails to match, fail overall if the minimum number of occurrences has not yet been met. Otherwise, succeed overall, consuming all bytes from the occurrences that succeeded (not consuming any bytes from the final failing occurrence). Like Pattern::Optional, this pattern will never fail if @min is zero.

Defined in:

pegmatite/pattern/repeat.cr

Constructors

Instance Method Summary

Instance methods inherited from class Pegmatite::Pattern

_match(source, offset, state) : MatchResult _match, match(source, offset, state) : MatchResult match

Instance methods inherited from module Pegmatite::DSL::Methods

>>(other) >>, ^(other) ^, |(other) |, ~ ~, dynamic_pop(label) dynamic_pop, dynamic_push(label) dynamic_push, maybe maybe, named(label, tokenize = true) named, repeat(min = 0, max = nil) repeat, repeat_exactly(times) repeat_exactly, then_eof then_eof

Constructor Detail

def self.new(child : Pattern, min : Int32 = 0, max = nil) #

[View source]

Instance Method Detail

def _match(source, offset, state) : MatchResult #

[View source]
def description #

[View source]
def dsl_name #

[View source]
def inspect(io) #

[View source]