Class: Spectre::Operators::Difference
- Inherits:
-
Object
- Object
- Spectre::Operators::Difference
- Includes:
- Op
- Defined in:
- lib/spectre/base/operators.rb
Overview
Matches if the first Node matches, but not the second or if both match and the first one’s match is longer. Difference.new p1, p2 is equal to p1 - p2.
Instance Attribute Summary
Attributes included from Parser
Instance Method Summary collapse
Methods included from Op
Methods included from Parser
#backtrack, #create_match, from_POD, #pre_skip?, #to_p
Instance Method Details
#inspect ⇒ Object
186 187 188 |
# File 'lib/spectre/base/operators.rb', line 186 def inspect '(' + @node.left.inspect + ' - ' + @node.right.inspect + ')' end |
#scan(iter) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/spectre/base/operators.rb', line 169 def scan iter first = @node.left.parse iter fiter = iter.dup backtrack iter return nil unless first second = @node.right.parse iter backtrack iter if ( first and not second ) or ( first.length > second.length ) iter.to fiter.pos create_match iter, first else nil end end |