Class: MetaParse::AlternativeMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/meta_parse.rb

Overview

Matcher subclass matching first of alternative submatches.

Instance Attribute Summary

Attributes inherited from Matcher

#spec

Instance Method Summary collapse

Methods inherited from Matcher

compile, #initialize, #inspect, #m, #m?, #match, #stateful

Constructor Details

This class inherits a constructor from MetaParse::Matcher

Instance Method Details

#match?(scanner, context = nil) ⇒ Boolean



325
326
327
328
329
330
331
# File 'lib/meta_parse.rb', line 325

def match?(scanner, context=nil)
  spec.each do |alternative|
    result = alternative.match(scanner)
    return result if result
  end
  return nil
end

#showObject



333
334
335
# File 'lib/meta_parse.rb', line 333

def show
  "first of: (#{ (spec.map &:show).join ', ' })"
end