feat(tpc): 解析错误记录具体 token 位置(消除'第 0 行 0 列'不可读错误)
This commit is contained in:
1 parent
60dbdfe8d2
commit
bc017d0a61
1 file changed
+2
-3
@@ -1038,9 +1038,7 @@ def _parse_atom(ps: Parser | t.CPtr) -> AST | t.CPtr:
|
||||
if _match_op(ps, TokOp.LBrace):
|
||||
return _parse_brace(ps)
|
||||
|
||||
stdio.printf("[DBG-atom-fail] line=%d col=%d type=%d str='%s' op_id=%d\n",
|
||||
_cur_lineno(ps), _cur_col(ps), _cur_type(ps),
|
||||
_cur_str(ps) if _cur_str(ps) is not None else "(null)", _cur_op(ps))
|
||||
_record_parse_err(ps)
|
||||
ps.error_count += 1
|
||||
return None
|
||||
|
||||
@@ -1575,6 +1573,7 @@ def _parse_type_ann(ps: Parser | t.CPtr) -> AST | t.CPtr:
|
||||
before_ec: t.CInt = ps.error_count
|
||||
base: AST | t.CPtr = _parse_test(ps)
|
||||
if base is None:
|
||||
_record_parse_err(ps) # 注解解析失败:记录具体位置(error_count 已在 _parse_test 内增加)
|
||||
return None
|
||||
ptr_level: t.CInt = 0
|
||||
# 回收垃圾节点(_parse_test 对后缀 * / ** 的消费产物)
|
||||
|
||||
Reference in new issue
Block a user