Class: Spectre::Operators::SequentialOr

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, but if one of the two does not match, it doesn’t matter SequentialOr.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



72
73
74
# File 'lib/spectre/base/operators.rb', line 72

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

#scan(iter) ⇒ Object



66
67
68
69
70
# File 'lib/spectre/base/operators.rb', line 66

def scan iter
    rep = ( @node.left.dup >> -@node.right.dup ) | @node.right.dup
    rep = @node.replace_with rep
    create_match iter, rep.parse(iter)
end