Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 ( If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit a33838c1 authored by eckhart's avatar eckhart
Browse files

- DHParser/ MetaParser._return_values(): flatten anonymous nodes already while parsing

parent cd0e4a9e
DHParser Version 0.8.5 (DATE?)
- pending optimization: flattens anonymous nodes already while parsing
- optimization: flattens anonymous nodes already while parsing
- optimization: drops empty anonymous nodes already during parsing
- optimization: optionally allows to drop anonymous whitespace and tokens
while parsing
......@@ -1247,6 +1247,7 @@ class DropWhitespace(Whitespace):
class MetaParser(Parser):
# TODO: Allow to turn optimization off
def _return_value(self, node: Optional[Node]) -> Node:
# Node(self.tag_name, node) # unoptimized code
......@@ -1267,9 +1268,14 @@ class MetaParser(Parser):
# return Node(self.tag_name, results) # unoptimized code
assert isinstance(results, tuple)
N = len(results)
# TODO: if N >= 2, flatten results!
if N > 1:
return Node(self.tag_name, results)
nr = []
for child in results:
if child.children and child.tag_name[0] == ':': # faster than c.is_anonymous():
return Node(self.tag_name, tuple(nr))
elif N == 1:
return self._return_value(results[0])
elif self.pname:
......@@ -99,8 +99,8 @@ class TestLoggingAndLoading:
except AttributeError:
with logging("TESTLOGS"):
assert not os.path.exists("TESTSLOGS"), \
"Log dir should not be created before first use!"
assert os.path.exists("TESTLOGS"), \
"Log dir should be created if it does not exist!"
dirname = log_dir()
assert dirname == "TESTLOGS"
assert is_logging(), "is_logging() should return True, if logging is on"
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