Do proper error recover for fstrings and fix another issue there.

This commit is contained in:
Dave Halter
2017-08-26 12:02:10 +02:00
parent 1893f77e15
commit 68cc383d02
3 changed files with 19 additions and 7 deletions

View File

@@ -198,9 +198,17 @@ class Parser(parser.BaseParser):
add_token_callback
)
dfa, state, (type_, nodes) = stack[1]
stack[0][2][1].append(ErrorNode(nodes))
stack[1:] = []
#error_leaf = tree.PythonErrorLeaf(tok_name[typ].lower(), value, start_pos, prefix)
if len(stack) == 1:
error_leaf = ErrorLeaf(
TokenNamespace.token_map[typ].lower(),
value,
start_pos,
prefix
)
stack[0][2][1].append(error_leaf)
else:
dfa, state, (type_, nodes) = stack[1]
stack[0][2][1].append(ErrorNode(nodes))
stack[1:] = []
add_token_callback(typ, value, start_pos, prefix)
add_token_callback(typ, value, start_pos, prefix)