Class: Spectre::Negations::NegatedSingleTokenParser

Inherits:
Operators::Negation show all
Includes:
Parser
Defined in:
lib/spectre/generic/negations.rb

Overview

Negates a Parser that will consume a single token only.

Instance Attribute Summary

Attributes included from Parser

#node

Instance Method Summary collapse

Methods included from Parser

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

Methods inherited from Operators::Negation

#inspect

Instance Method Details

#scan(iter) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/spectre/generic/negations.rb', line 36

def scan iter
    token = iter.get
    ret = @node.left.parse iter
    backtrack iter

    if ret
        nil
    else
        +iter
        create_match iter, token
    end
end