Package lepl :: Package stream :: Module simple :: Class StringHelper
[hide private]
[frames] | no frames]

Class StringHelper

source code


String-specific fmtting and location.
Instance Methods [hide private]
 
__init__(self, sequence, id=None, factory=None, max=None, global_kargs=None, cache_level=None, delta=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_fmt(self, sequence, offset, maxlen=60, left="'", right="'", index=True)
fmt a possibly long subsection of data.
source code
 
_location(self, kargs, prefix)
Location (separate method so subclasses can replace).
source code
 
delta(self, state)
Return the offset, lineno and char of the current point, relative to the entire stream, as a tuple.
source code
 
kargs(self, state, prefix='', kargs=None)
Generate a dictionary of values that describe the stream.
source code
 
join(self, state, *values)
Join sequences of values into a single sequence.
source code
 
line(self, state, empty_ok)
Returns up to, and including then next
source code
 
stream(self, state, value, id_=None, max=None)
Return a new stream that encapsulates the value given, starting at state.
source code

Inherited from SequenceHelper: debug, deepest, empty, key, len, new_max, next

Inherited from SequenceHelper (private): _typename

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Inherited from core.StreamHelper: __eq__, cacheable, eq, fmt

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sequence, id=None, factory=None, max=None, global_kargs=None, cache_level=None, delta=None)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: core.StreamHelper.__init__

_fmt(self, sequence, offset, maxlen=60, left="'", right="'", index=True)

source code 
fmt a possibly long subsection of data.
Overrides: SequenceHelper._fmt
(inherited documentation)

_location(self, kargs, prefix)

source code 
Location (separate method so subclasses can replace).
Overrides: SequenceHelper._location
(inherited documentation)

delta(self, state)

source code 
Return the offset, lineno and char of the current point, relative to the entire stream, as a tuple.
Overrides: core.StreamHelper.delta
(inherited documentation)

kargs(self, state, prefix='', kargs=None)

source code 

Generate a dictionary of values that describe the stream. These may be extended by subclasses. They are provided to syntax_error_kargs, for example.

Note: Calculating this can be expensive; use only for error messages, not debug messages (that may be discarded).

Implementation note: Because some values are

Overrides: core.StreamHelper.kargs
(inherited documentation)

join(self, state, *values)

source code 
Join sequences of values into a single sequence.
Overrides: core.StreamHelper.join
(inherited documentation)

line(self, state, empty_ok)

source code 
Returns up to, and including then next
Overrides: core.StreamHelper.line

stream(self, state, value, id_=None, max=None)

source code 

Return a new stream that encapsulates the value given, starting at state. IMPORTANT: the stream used is the one that corresponds to the start of the value.

For example:

(line, next_stream) = s_line(stream, False) token_stream = s_stream(stream, line) # uses stream, not next_stream

This is used when processing Tokens, for example, or columns (where fragments in the correct column area are parsed separately).

Overrides: core.StreamHelper.stream
(inherited documentation)