Class: MetaParse::AlternativeMatcher

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

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

Returns:

  • (Boolean)


233
234
235
236
237
238
239
# File 'lib/meta_parse.rb', line 233

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

#showObject



241
242
243
# File 'lib/meta_parse.rb', line 241

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