Package lepl :: Package matchers :: Module core :: Class Lookahead
[hide private]
[frames] | no frames]

Class Lookahead

source code


Tests to see if the embedded matcher could match, but does not do the matching. On success an empty list (ie no result) and the original stream are returned.

When negated (preceded by ~) the behaviour is reversed - success occurs only if the embedded matcher would fail to match.

This is a consumer because it's correct functioning depends directly on the stream's contents.

Instance Methods [hide private]
 
__init__(self, matcher, negated=False)
On success, no input is consumed.
source code
 
_match(self, stream)
Do the matching (return a generator that provides successive (result, stream) tuples).
source code
 
__invert__(self)
Invert the semantics (this overrides the usual meaning for ~).
source code

Inherited from operators.OperatorMixin: __add__, __and__, __div__, __floordiv__, __ge__, __getitem__, __gt__, __mod__, __or__, __pow__, __radd__, __rand__, __rdiv__, __rfloordiv__, __rmod__, __ror__, __rshift__, __rtruediv__, __truediv__, __xor__

Inherited from support.context.NamespaceMixin (private): _lookup

Inherited from core.config.ParserMixin: get_match, get_match_file, get_match_iterable, get_match_list, get_match_sequence, get_match_string, get_parse, get_parse_all, get_parse_file, get_parse_file_all, get_parse_iterable, get_parse_iterable_all, get_parse_list, get_parse_list_all, get_parse_sequence, get_parse_sequence_all, get_parse_string, get_parse_string_all, match, match_file, match_iterable, match_list, match_sequence, match_string, parse, parse_all, parse_file, parse_file_all, parse_iterable, parse_iterable_all, parse_list, parse_list_all, parse_sequence, parse_sequence_all, parse_string, parse_string_all

Inherited from core.config.ParserMixin (private): _raw_parser

Inherited from support.BaseMatcher: __repr__, __str__, clone, kargs, tree, tree_repr

Inherited from support.graph.ArgAsAttributeMixin: __iter__

Inherited from support.graph.PostorderWalkerMixin: postorder

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

Inherited from matcher.Matcher: indented_repr

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, matcher, negated=False)
(Constructor)

source code 
On success, no input is consumed. If negated, this will succeed if the matcher fails. If the matcher is a string it is coerced to a literal match.
Overrides: matcher.Matcher.__init__

_match(self, stream)

source code 
Do the matching (return a generator that provides successive (result, stream) tuples).
Decorators:
  • @tagged
Overrides: matcher.Matcher._match

__invert__(self)

source code 
Invert the semantics (this overrides the usual meaning for ~).
Overrides: operators.OperatorMixin.__invert__