Class: MetaParse::SequentialMatcher

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

Instance Attribute Summary collapse

Attributes inherited from Matcher

#spec

Instance Method Summary collapse

Methods inherited from Matcher

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

Constructor Details

This class inherits a constructor from MetaParse::Matcher

Instance Attribute Details

#matchesObject

Returns the value of attribute matches.



247
248
249
# File 'lib/meta_parse.rb', line 247

def matches
  @matches
end

Instance Method Details

#clearObject



277
278
279
# File 'lib/meta_parse.rb', line 277

def clear
  @matches = []
end

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

Returns:

  • (Boolean)


253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/meta_parse.rb', line 253

def match?(scanner, context = nil)
  @matches = []
  initial_position = scanner.pos
  last_match = nil

  spec.each do |element|
    last_match = element.match(scanner, self)
    unless last_match
      scanner.pos = initial_position
      return nil
    end
    @matches << last_match
  end
  return last_match
end

#popObject



269
270
271
# File 'lib/meta_parse.rb', line 269

def pop
  @matches.pop
end

#push(value) ⇒ Object



273
274
275
# File 'lib/meta_parse.rb', line 273

def push(value)
  @matches.push(value)
end

#showObject



281
282
283
# File 'lib/meta_parse.rb', line 281

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

#statefulObject



249
250
251
# File 'lib/meta_parse.rb', line 249

def stateful
  true
end