Commit b32bef7c authored by di68kap's avatar di68kap

- pos value in history record

parent 49f1e4c1
......@@ -216,7 +216,7 @@ class HistoryRecord:
parser call, which ist either MATCH, FAIL (i.e. no match)
or ERROR.
"""
__slots__ = ('call_stack', 'node', 'text', 'line_col', 'errors')
__slots__ = ('call_stack', 'node', 'text', 'pos', 'line_col', 'errors')
MATCH = "MATCH"
ERROR = "ERROR"
......@@ -245,14 +245,14 @@ class HistoryRecord:
def __init__(self, call_stack: List[str],
node: Optional[Node],
text: StringView,
# pos: int,
pos: int,
line_col: Tuple[int, int],
errors: List[Error] = []) -> None:
# copy call stack, dropping uninformative Forward-Parsers
self.call_stack = [tn for tn in call_stack if tn != ":Forward"] # type: List[str]
self.node = node # type: Optional[Node]
self.text = text # type: StringView
# self.pos = pos # type: int
self.pos = pos # type: int
self.line_col = line_col # type: Tuple[int, int]
self.errors = errors # type: List[Error]
......
......@@ -382,13 +382,13 @@ class Parser:
# remaining = len(rest)
if grammar.moving_forward__:
record = HistoryRecord(grammar.call_stack__, node, text,
grammar.line_col__(text))
location, grammar.line_col__(text))
grammar.history__.append(record)
elif error:
# error_nid = id(node) # type: int
# if error_nid in grammar.tree__.error_nodes:
record = HistoryRecord(grammar.call_stack__, node, text,
grammar.line_col__(text),
location, grammar.line_col__(text),
[error])
grammar.history__.append(record)
grammar.moving_forward__ = False
......@@ -1012,7 +1012,7 @@ class Grammar:
if h.node and h.node.tag_name != EMPTY_NODE.tag_name:
break
else:
h = HistoryRecord([], None, StringView(''), (0, 0))
h = HistoryRecord([], None, StringView(''), 0, (0, 0))
if h.status == h.MATCH and (h.node.pos + len(h.node) == len(self.document__)):
# TODO: this case still needs unit-tests and support in testing.py
error_msg = "Parser stopped before end, but matched with lookahead."
......
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