In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see for more information.

Commit 506cd427 authored by Eckhart Arnold's avatar Eckhart Arnold

- some cleanups

parent 909142bd
......@@ -425,10 +425,14 @@ class Parser(ParserBase):
Applies function `func(parser)` recursively to this parser and all
descendant parsers if any exist. The same function can never
be applied twice between calls of the ``reset()``-method!
Returns `True`, if function has been applied, `False` if function
had been applied earlier already and thus has not been applied again.
if func in self.cycle_detection:
return False
assert not self.visited, "No calls to Parser.apply() during or " \
"after ongoing parsing process. (Call Parser.reset() first.)"
return True
......@@ -1147,7 +1151,7 @@ class RE(Parser):
self.wspRight = self.grammar.wsp_right_parser__
def apply(self, func: Parser.ApplyFunc) -> bool:
if super(RE, self).apply(func):
if super().apply(func):
if self.wL:
if self.wR:
......@@ -1208,7 +1212,7 @@ class UnaryOperator(Parser):
return self.__class__(parser,
def apply(self, func: Parser.ApplyFunc) -> bool:
if super(UnaryOperator, self).apply(func):
if super().apply(func):
return True
return False
......@@ -1235,7 +1239,7 @@ class NaryOperator(Parser):
return self.__class__(*parsers,
def apply(self, func: Parser.ApplyFunc) -> bool:
if super(NaryOperator, self).apply(func):
if super().apply(func):
for parser in self.parsers:
return True
......@@ -1906,8 +1910,7 @@ class Forward(Parser):
self.parser = parser
def apply(self, func: Parser.ApplyFunc) -> bool:
if super(Forward, self).apply(func):
assert not self.visited
if super().apply(func):
return True
return False
......@@ -145,6 +145,7 @@ ZOMBIE_PARSER = ZombieParser()
ChildrenType = Tuple['Node', ...]
NoChildren = cast(ChildrenType, ()) # type: ChildrenType
StrictResultType = Union[ChildrenType, StringView, str]
ResultType = Union[ChildrenType, 'Node', StringView, str, None]
......@@ -285,7 +286,7 @@ class Node(
# self._result = (result,) if isinstance(result, Node) else str(result) \
# if isinstance(result, StringView) else result or '' # type: StrictResultType
self.children = cast(ChildrenType, self._result) \
if isinstance(self._result, tuple) else cast(ChildrenType, ()) # type: ChildrenType
if isinstance(self._result, tuple) else NoChildren # type: ChildrenType
if self.children:
self.error_flag = max(self.error_flag,
max(child.error_flag for child in self.children)) # type: bool
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment