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
303
304
305
306
307
|
# File 'lib/kpeg/grammar.rb', line 303
def initialize(*ops)
super()
@ops = ops
detect_tags ops
end
|
Instance Attribute Details
#ops ⇒ Object
Returns the value of attribute ops.
309
310
311
|
# File 'lib/kpeg/grammar.rb', line 309
def ops
@ops
end
|
Instance Method Details
#==(obj) ⇒ Object
324
325
326
327
328
329
330
331
|
# File 'lib/kpeg/grammar.rb', line 324
def ==(obj)
case obj
when Sequence
@ops == obj.ops
else
super
end
end
|
#inspect ⇒ Object
333
334
335
|
# File 'lib/kpeg/grammar.rb', line 333
def inspect
inspect_type "seq", @ops.map { |i| i.inspect }.join(' ')
end
|
#match(x) ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
|
# File 'lib/kpeg/grammar.rb', line 311
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
|