Package lepl :: Package lexer :: Package lines :: Module matchers :: Class Block
[hide private]
[frames] | no frames]

Class Block

source code


Set a new indent level for the enclosed matchers (typically BLine and Block instances).

In the simplest case, this might increment the global indent by 4, say. In a more complex case it might look at the current token, expecting an Indent, and set the global indent at that amount if it is larger than the current value.

A block will always match an Indent, but will not consume it (it will remain in the stream after the block has finished).

The usual memoization of left recursive calls will not detect problems with nested blocks (because the indentation changes), so instead we track and block nested calls manually.

Instance Methods [hide private]
 
__init__(self, *lines, **kargs)
Lines are invoked in sequence (like And()).
source code
 
on_push(self, monitor)
Store a reference to the monitor which we will update inside _match
source code
 
on_pop(self, monitor) source code
 
_match(self, stream_in)
Pull indent and call the policy and update the global value, then evaluate the contents.
source code

Inherited from matchers.operators.OperatorMixin: __add__, __and__, __div__, __floordiv__, __ge__, __getitem__, __gt__, __invert__, __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 matchers.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 matchers.matcher.Matcher: indented_repr

Class Variables [hide private]
  POLICY = 'policy'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, *lines, **kargs)
(Constructor)

source code 

Lines are invoked in sequence (like And()).

The policy is passed the current level and the indent and must return a new level. Typically it is set globally by rewriting with a default in the configuration. If it is given as an integer then constant_indent is used to create a policy from that.

indent is the matcher used to match indents, and is exposed for rewriting/extension (in other words, ignore it).

Overrides: matchers.matcher.Matcher.__init__

_match(self, stream_in)

source code 
Pull indent and call the policy and update the global value, then evaluate the contents.
Decorators:
  • @tagged
Overrides: matchers.matcher.Matcher._match