Class: Spectre::Directives::EpsilonDirective

Inherits:
Spectre::Directive show all
Defined in:
lib/spectre/generic/directives.rb

Overview

Matches, if the Parser it wraps around matches, but reduces that Match to 0 length, i.e. will never consume any input. Shortcut: epsilon or e.

Instance Attribute Summary

Attributes inherited from Spectre::Directive

#iter_skipper, #iter_transformation, #pre_skip

Attributes inherited from Node

#actions, #backtrace, #left, #parent, #parser, #policy, #right, #symbols

Instance Method Summary collapse

Methods inherited from Spectre::Directive

#[], #initialize, policy, policy!, skipper!, transformation!

Methods inherited from Node

#%, #&, #*, #**, #+, #-, #-@, #>>, #[], #^, #backtrack, #chain, #closure, #closure=, #closure?, #find, #initialize, #initialize_copy, #leaf?, #replace_with, #root?, #shallow_copy, #to_p, #|, #~@

Constructor Details

This class inherits a constructor from Spectre::Directive

Instance Method Details

#inspectObject



237
238
239
# File 'lib/spectre/generic/directives.rb', line 237

def inspect
    "[e:#{@node.left.inspect}]"
end

#parse(iter, *args) ⇒ Object



230
231
232
233
234
235
# File 'lib/spectre/generic/directives.rb', line 230

def parse iter, *args
    ret = super(iter, *args)
    backtrack iter
    ret.length = 0 if ret
    ret
end