feat(lexer): 在换行符处理时添加流回退功能

在词法分析器中遇到换行符时,添加对 scc_probe_stream_back 的调用,
以确保流探针位置正确回退。同时修正了 probe_stream_t 接口定义中的
注释说明,明确 back 函数的作用是后退探针位置而非头指针位置。

修复了内存探针流实现中回退逻辑的边界条件判断,
现在能够正确处理探针位置的回退操作。
This commit is contained in:
zzy
2026-01-11 14:20:54 +08:00
parent 6c801fbb92
commit 84cff78b86
3 changed files with 9 additions and 7 deletions

View File

@@ -59,12 +59,13 @@ static cbool mem_probe_stream_back(scc_probe_stream_t *_stream) {
Assert(_stream != null);
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
// 只能回退一个字符,且不能回退到探针位置之前
if (stream->curr_pos == 0 || stream->curr_pos <= stream->probe_pos) {
// 只能回退一个字符
if (stream->probe_pos == 0)
return false;
if (stream->curr_pos + 1 > stream->probe_pos)
return false;
}
stream->curr_pos--;
stream->probe_pos--;
return true;
}