Class: Spectre::Operators::Positive

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

Overview

Matches the given Node 1 or more times. Positive.new p is equal to p.+.

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



292
293
294
# File 'lib/spectre/base/operators.rb', line 292

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

#scan(iter) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/spectre/base/operators.rb', line 279

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

    val = ret.value
    while ret
        ret = @node.left.parse iter
        val = iter.concat val, ret.value if ret
    end

    create_match iter, val
end