Class: Spectre::Operators::Sequence

Inherits:
Object
  • Object
show all
Includes:
Op
Defined in:
lib/spectre/base/operators.rb

Overview

Takes the two Nodes it gets as parameters and tries to match them one after the other. Sequence.new p1, p2 is equal to p1 >> p2.

Instance Attribute Summary

Attributes included from Parser

#node

Instance Method Summary collapse

Methods included from Op

#pre_skip?

Methods included from Parser

#backtrack, #create_match, from_POD, #pre_skip?, #to_p

Instance Method Details

#inspectObject



53
54
55
# File 'lib/spectre/base/operators.rb', line 53

def inspect
    '(' + @node.left.inspect + ' >> ' + @node.right.inspect + ')'
end

#scan(iter) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/spectre/base/operators.rb', line 43

def scan iter
    first = @node.left.parse iter
    return nil unless first

    second = @node.right.parse iter
    return nil unless second

    create_match iter, iter.concat(first.value, second.value)
end