Class: KPeg::Sequence
Instance Attribute Summary collapse
Attributes inherited from Operator
#action
Instance Method Summary
collapse
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action, #|
Constructor Details
#initialize(*ops) ⇒ Sequence
293
294
295
296
297
|
# File 'lib/kpeg/grammar.rb', line 293
def initialize(*ops)
super()
@ops = ops
detect_tags ops
end
|
Instance Attribute Details
#ops ⇒ Object
Returns the value of attribute ops.
299
300
301
|
# File 'lib/kpeg/grammar.rb', line 299
def ops
@ops
end
|
Instance Method Details
#==(obj) ⇒ Object
314
315
316
317
318
319
320
321
|
# File 'lib/kpeg/grammar.rb', line 314
def ==(obj)
case obj
when Sequence
@ops == obj.ops
else
super
end
end
|
#inspect ⇒ Object
323
324
325
|
# File 'lib/kpeg/grammar.rb', line 323
def inspect
inspect_type "seq", @ops.map { |i| i.inspect }.join(' ')
end
|
#match(x) ⇒ Object
301
302
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/kpeg/grammar.rb', line 301
def match(x)
start = x.pos
matches = @ops.map do |n|
m = n.match(x)
unless m
x.pos = start
return nil
end
m
end
MatchComposition.new(self, matches)
end
|