refactor(lex_parser): replace core_pos_* functions with scc_pos_* equivalents
Update all position tracking calls in lex_parser.c to use the scc_pos_* function family (scc_pos_next, scc_pos_next_line) instead of the deprecated core_pos_* variants. This ensures consistency with the scc naming convention and prepares for future removal of the old core functions.
This commit is contained in:
@@ -10,10 +10,10 @@ void lex_parse_skip_endline(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
if (ch == '\n') {
|
||||
scc_probe_stream_consume(input);
|
||||
}
|
||||
core_pos_next_line(pos);
|
||||
scc_pos_next_line(pos);
|
||||
} else if (ch == '\n') {
|
||||
scc_probe_stream_consume(input);
|
||||
core_pos_next_line(pos);
|
||||
scc_pos_next_line(pos);
|
||||
} else {
|
||||
LOG_WARN("not a newline character");
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void lex_parse_skip_line(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
return;
|
||||
} else {
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,11 +85,11 @@ void lex_parse_skip_block_comment(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
int ch;
|
||||
scc_probe_stream_reset(stream);
|
||||
ch = scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
// FIXME Assertion
|
||||
Assert(ch == '/');
|
||||
ch = scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
Assert(ch == '*');
|
||||
|
||||
// all ready match `/*`
|
||||
@@ -107,12 +107,12 @@ void lex_parse_skip_block_comment(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
continue;
|
||||
}
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
if (ch == '*') {
|
||||
ch = scc_probe_stream_peek(stream);
|
||||
if (ch == '/') {
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ void lex_parse_skip_whitespace(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
}
|
||||
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ static inline cbool _lex_parse_uint(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
}
|
||||
|
||||
scc_probe_stream_consume(input);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
n = n * base + tmp;
|
||||
// TODO number overflow
|
||||
}
|
||||
@@ -202,17 +202,17 @@ int lex_parse_char(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
goto ERR;
|
||||
}
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
|
||||
ch = scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
|
||||
if (ch == core_stream_eof) {
|
||||
LOG_WARN("Unexpected EOF at middle");
|
||||
goto ERR;
|
||||
} else if (ch == '\\') {
|
||||
ch = scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
if (ch == '0') {
|
||||
// 数字转义序列
|
||||
// \nnn 任意八进制值 码元 nnn
|
||||
@@ -239,7 +239,7 @@ int lex_parse_char(scc_probe_stream_t *input, scc_pos_t *pos) {
|
||||
}
|
||||
if ((ch = scc_probe_stream_consume(stream)) != '\'') {
|
||||
LOG_ERROR("Unclosed character literal '%c' at end, expect `'`", ch);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
goto ERR;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ cbool lex_parse_string(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
goto ERR;
|
||||
}
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
|
||||
scc_cstring_t str = scc_cstring_from_cstr("");
|
||||
while (1) {
|
||||
@@ -298,12 +298,12 @@ cbool lex_parse_string(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
}
|
||||
} else if (ch == '"') {
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
break;
|
||||
}
|
||||
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
scc_cstring_append_ch(&str, ch);
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ cbool lex_parse_number(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
if (ch == '0') {
|
||||
// 消费 '0'
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
|
||||
// 查看下一个字符
|
||||
ch = scc_probe_stream_peek(stream);
|
||||
@@ -347,12 +347,12 @@ cbool lex_parse_number(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
// 十六进制
|
||||
base = 16;
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
} else if (ch == 'b' || ch == 'B') {
|
||||
// 二进制 (C23扩展)
|
||||
base = 2;
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
} else if (ch >= '0' && ch <= '7') {
|
||||
// 八进制
|
||||
base = 8;
|
||||
@@ -384,7 +384,7 @@ cbool lex_parse_number(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
// 我们需要消费这个数字并返回它的值
|
||||
if (ch >= '1' && ch <= '9') {
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
*output = ch - '0';
|
||||
return true;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ cbool lex_parse_identifier(scc_probe_stream_t *input, scc_pos_t *pos,
|
||||
while (1) {
|
||||
scc_cstring_append_ch(output, ch);
|
||||
scc_probe_stream_consume(stream);
|
||||
core_pos_next(pos);
|
||||
scc_pos_next(pos);
|
||||
ch = scc_probe_stream_peek(stream);
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
|
||||
(ch == '_') || (ch >= '0' && ch <= '9')) {
|
||||
|
||||
Reference in New Issue
Block a user