Class: Spectre::Operators::List

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

Overview

Matches a list of tokens matched by the first Node, separated by tokens matched by the second Node. The first Node must not match the second. List.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



334
335
336
# File 'lib/spectre/base/operators.rb', line 334

def inspect
    "(#{@node.left.inspect} % #{@node.right.inspect})"
end

#scan(iter) ⇒ Object



328
329
330
331
332
# File 'lib/spectre/base/operators.rb', line 328

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