Class: Spectre::StringParsing::StringInputIterator

Inherits:
InputIterator
  • Object
show all
Defined in:
lib/spectre/string/inputiterator.rb

Overview

The standard input provider for Strings. The default transformation set will skip white-space (s, n, t, r, f). This can be undone by wrapping the Parser(s) inside a lexeme_d.

Instance Attribute Summary

Attributes inherited from InputIterator

#input, #pos, #skipper, #transformation

Instance Method Summary collapse

Methods inherited from InputIterator

#+, #+@, #-, #default_transformation, #get, #ignore_skipper, #initialize, #initialize_copy, #rest, #skip!, #to, #valid?

Constructor Details

This class inherits a constructor from Spectre::InputIterator

Instance Method Details

#concat(val1, val2) ⇒ Object



46
47
48
# File 'lib/spectre/string/inputiterator.rb', line 46

def concat val1, val2
    ( val1 || '' ) + ( val2 || '' )
end

#default_skipperObject

The default skipper for this InputIterator class. Skips white space.



37
38
39
40
41
42
43
44
# File 'lib/spectre/string/inputiterator.rb', line 37

def default_skipper
    lambda { |token,is|
        case token
        when " ", "\n", "\r", "\t", "\f" then 1
        else nil
        end
    }
end

#emptyObject



50
51
52
# File 'lib/spectre/string/inputiterator.rb', line 50

def empty
    ''
end