Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). 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 3558cc35 authored by eckhart's avatar eckhart
Browse files

- compile.compile_source: removed unecessary error collecting calls

parent b30733c0
......@@ -249,19 +249,20 @@ def compile_source(source: str,
# only compile if there were no syntax errors, for otherwise it is
# likely that error list gets littered with compile error messages
result = None
efl = syntax_tree.error_flag
messages = syntax_tree.collect_errors(clear_errors=True)
if not is_error(efl):
# efl = syntax_tree.error_flag
# messages = syntax_tree.collect_errors(clear_errors=True)
if not is_error(syntax_tree.error_flag):
transformer(syntax_tree)
efl = max(efl, syntax_tree.error_flag)
messages.extend(syntax_tree.collect_errors(clear_errors=True))
# efl = max(efl, syntax_tree.error_flag)
# messages.extend(syntax_tree.collect_errors(clear_errors=True))
if is_logging():
log_ST(syntax_tree, log_file_name + '.ast')
if not is_error(syntax_tree.error_flag):
result = compiler(syntax_tree)
# print(syntax_tree.as_sxpr())
messages.extend(syntax_tree.collect_errors())
syntax_tree.error_flag = max(syntax_tree.error_flag, efl)
# messages.extend(syntax_tree.collect_errors())
# syntax_tree.error_flag = max(syntax_tree.error_flag, efl)
messages = syntax_tree.collect_errors()
adjust_error_locations(messages, original_text, source_mapping)
return result, messages, syntax_tree
......@@ -84,10 +84,12 @@ class Error:
self.orig_pos = orig_pos
self.line = line
self.column = column
self._node = node
if node is not None:
if node is not None and node._pos >= 0:
assert self._pos < 0 or self._pos == node._pos
self._pos = node._pos
self._node = None # if node is not needed, if pos has been set
else:
self._node = node
def __str__(self):
prefix = ''
......@@ -102,12 +104,11 @@ class Error:
@property
def pos(self):
if self._pos < 0:
assert self._node and self._node.pos >= 0
assert self._node and self._node.pos >= 0, "pos value not ready yet"
self._pos = self._node.pos # lazy evaluation of position
self._node = None # forget node to allow GC to free memory
return self._pos
@property
def severity(self):
"""Returns a string representation of the error level, e.g. "warning"."""
......
......@@ -751,6 +751,8 @@ class RootNode(Node):
# err.pos = node.pos
self.all_errors.sort(key=lambda e: e.pos)
errors = self.all_errors
for error in self.all_errors:
_ = error.pos
if clear_errors:
self.all_errors = []
self.error_flag = 0
......
......@@ -106,7 +106,7 @@ Fail-test "10"
Error: Parser did not match! Invalid source file?
Most advanced: None
Last match: None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x7f2f0767de18>, {'NAME': ['generic']})
Fail-test "11"
--------------
......@@ -123,7 +123,7 @@ Error: Parser did not match! Invalid source file?
Error: Parser did not match! Invalid source file?
Most advanced: None
Last match: None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93598>, {'NAME': ['generic']})
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x7f2f0767dd90>, {'NAME': ['generic']})
Fail-test "12"
--------------
......@@ -135,7 +135,7 @@ Fail-test "12"
### Messages:
Error: -&LB end_environment LFF expected; "\end{gener" found!
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x7f2f0767de18>, {'NAME': ['generic']})
Test of parser: "inline_environment"
......@@ -215,7 +215,7 @@ Error: Parser did not match! Invalid source file?
Error: Parser did not match! Invalid source file?
Most advanced: None
Last match: None;
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x0000000003A93488>, {'NAME': ['generic']})
Error: Capture-retrieve-stack not empty after end of parsing: defaultdict(<function Grammar._reset__.<locals>.<lambda> at 0x7f2f0767de18>, {'NAME': ['generic']})
Test of parser: "itemize"
......
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