feat(lex_parser, pprocessor): replace consume with next and remove stream resets

- Replace `scc_probe_stream_consume` with `scc_probe_stream_next` for consistent stream advancement
- Remove redundant `scc_probe_stream_reset` calls before peeking, as `next` and `peek` handle state
- Update `scc_cstring_new` to `scc_cstring_create` and `scc_pos_init` to `scc_pos_create` for naming consistency
- Change `scc_pp_macro_get` parameter to `const scc_cstring_t*` for better const-correctness
- Improves code clarity and maintains proper stream position tracking
This commit is contained in:
zzy
2025-12-28 10:49:29 +08:00
parent 07f5d9331b
commit 09f4ac8de0
20 changed files with 445 additions and 262 deletions

View File

@@ -4,22 +4,22 @@
/* clang-format off */
/// https://cppreference.cn/w/c/preprocessor
#define SCC_PP_INST_TOKEN \
X(define , SCC_PP_STD, SCC_PP_TOK_DEFINE ) \
X(elif , SCC_PP_STD, SCC_PP_TOK_UNDEF ) \
X(elifdef , SCC_PP_STD, SCC_PP_TOK_INCLUDE ) \
X(elifndef , SCC_PP_STD, SCC_PP_TOK_IF ) \
X(else , SCC_PP_STD, SCC_PP_TOK_IFDEF ) \
X(embed , SCC_PP_STD, SCC_PP_TOK_IFNDEF ) \
X(endif , SCC_PP_STD, SCC_PP_TOK_ELSE ) \
X(error , SCC_PP_STD, SCC_PP_TOK_ELIF ) \
X(if , SCC_PP_STD, SCC_PP_TOK_ELIFDEF ) \
X(ifdef , SCC_PP_C23, SCC_PP_TOK_ELIFNDEF ) \
X(ifndef , SCC_PP_STD, SCC_PP_TOK_ENDIF ) \
X(include , SCC_PP_STD, SCC_PP_TOK_LINE ) \
X(line , SCC_PP_C23, SCC_PP_TOK_EMBED ) \
X(pragma , SCC_PP_STD, SCC_PP_TOK_ERROR ) \
X(undef , SCC_PP_C23, SCC_PP_TOK_WARNING ) \
X(warning , SCC_PP_STD, SCC_PP_TOK_PRAMA ) \
X(define , SCC_PP_STD, SCC_PP_TOK_DEFINE ) \
X(elif , SCC_PP_STD, SCC_PP_TOK_ELIF ) \
X(elifdef , SCC_PP_STD, SCC_PP_TOK_ELIFDEF ) \
X(elifndef , SCC_PP_STD, SCC_PP_TOK_ELIFNDEF ) \
X(else , SCC_PP_STD, SCC_PP_TOK_ELSE ) \
X(embed , SCC_PP_STD, SCC_PP_TOK_EMBED ) \
X(endif , SCC_PP_STD, SCC_PP_TOK_ENDIF ) \
X(error , SCC_PP_STD, SCC_PP_TOK_ERROR ) \
X(if , SCC_PP_STD, SCC_PP_TOK_IF ) \
X(ifdef , SCC_PP_C23, SCC_PP_TOK_IFDEF ) \
X(ifndef , SCC_PP_STD, SCC_PP_TOK_IFNDEF ) \
X(include , SCC_PP_STD, SCC_PP_TOK_INCLUDE ) \
X(line , SCC_PP_C23, SCC_PP_TOK_LINE ) \
X(pragma , SCC_PP_STD, SCC_PP_TOK_PRAGMA ) \
X(undef , SCC_PP_C23, SCC_PP_TOK_UNDEF ) \
X(warning , SCC_PP_STD, SCC_PP_TOK_WARNING ) \
// END
/* clang-format on */