Class: Spectre::DirectiveParser

Inherits:
Object
  • Object
show all
Includes:
Parser
Defined in:
lib/spectre/base/directive.rb

Overview

Does the setting and resetting of the input transformation on the InputIterator.

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

Constructor Details

#initialize(directive) ⇒ DirectiveParser

Returns a new instance of DirectiveParser.



130
131
132
# File 'lib/spectre/base/directive.rb', line 130

def initialize directive
    @directive = directive
end

Instance Method Details

#scan(iter) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/spectre/base/directive.rb', line 134

def scan iter
    trans, skip = iter.transformation, iter.skipper
    iter.transformation = @directive.iter_transformation if @directive.iter_transformation
    iter.skipper = @directive.iter_skipper if @directive.iter_skipper

    ret = @node.left.parse iter, @directive.pre_skip

    iter.transformation, iter.skipper = trans, skip

    create_match iter, ret
end