Commit 7a65086b authored by eckhart's avatar eckhart

- bug fix: parse.History.excerpt: str not representation of StringView objects needed

parent 4160b2ae
......@@ -232,7 +232,7 @@ class HistoryRecord:
@property
def excerpt(self):
length = len(self.node) if self.node else len(self.text)
excerpt = str(self.node)[:min(length, 20)] if self.node else self.text[:20]
excerpt = str(self.node)[:min(length, 20)] if self.node else str(self.text[:20])
excerpt = escape_control_characters(excerpt)
if length > 20:
excerpt += '...'
......@@ -301,6 +301,7 @@ def add_parser_guard(parser_func):
# if location has already been visited by the current parser,
# return saved result
if location in parser.visited:
# no history recording in case of meomized results
return parser.visited[location]
if grammar.history_tracking__:
......@@ -343,6 +344,7 @@ def add_parser_guard(parser_func):
# matches will store its result in the cache
parser.visited[location] = (node, rest)
# Mind that meomized parser calls will not appear in the history record!
if grammar.history_tracking__:
# don't track returning parsers except in case an error has occurred
remaining = len(rest)
......
......@@ -84,6 +84,9 @@ class TestInfiLoopsAndRecursion:
syntax_tree = parser(snippet)
assert not syntax_tree.error_flag, syntax_tree.collect_errors()
assert snippet == str(syntax_tree)
if is_logging():
syntax_tree.log("test_LeftRecursion_indirect.cst")
parser.log_parsing_history__("test_LeftRecursion_indirect")
def test_inifinite_loops(self):
minilang = """not_forever = { // } \n"""
......
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