feat(lex_parser): rename functions and update header guard prefix

- Change header guard from `__SMCC_LEX_PARSER_H__` to `__SCC_LEX_PARSER_H__`
- Prefix all lexer functions with `scc_` (e.g., `lex_parse_char` → `scc_lex_parse_char`)
- Add new helper function `scc_lex_parse_is_identifier_header`
- Update references in source and test files to use new function names
- Replace `core_stream_eof` with `scc_stream_eof` for consistency
This commit is contained in:
zzy
2025-12-13 14:06:13 +08:00
parent 94d3f46fac
commit 874a58281f
17 changed files with 98 additions and 92 deletions

View File

@@ -8,7 +8,7 @@ cbool check_char(const char *str, int expect, int *output) {
scc_mem_probe_stream_t mem_stream;
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
*output = lex_parse_char(stream, &pos);
*output = scc_lex_parse_char(stream, &pos);
return *output == expect;
}
@@ -22,8 +22,8 @@ cbool check_char(const char *str, int expect, int *output) {
#define CHECK_CHAR_INVALID(str) \
do { \
int _output; \
check_char(str, core_stream_eof, &_output); \
TEST_CHECK(_output == core_stream_eof); \
check_char(str, scc_stream_eof, &_output); \
TEST_CHECK(_output == scc_stream_eof); \
} while (0)
void test_simple_char(void) {

View File

@@ -10,7 +10,7 @@ cbool check_identifier(const char *str, const char *expect,
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
cbool ret = lex_parse_identifier(stream, &pos, output);
cbool ret = scc_lex_parse_identifier(stream, &pos, output);
if (ret && expect) {
return strcmp(output->data, expect) == 0;
}

View File

@@ -9,7 +9,7 @@ cbool check(const char *str, usize expect, usize *output) {
scc_mem_probe_stream_t mem_stream;
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
return lex_parse_number(stream, &pos, output);
return scc_lex_parse_number(stream, &pos, output);
}
#define CHECK_VALID(str, expect) \

View File

@@ -9,13 +9,13 @@ void check_skip_block_comment(const char *str, const char *expect_remaining) {
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
lex_parse_skip_block_comment(stream, &pos);
scc_lex_parse_skip_block_comment(stream, &pos);
// Check remaining content
char buffer[256] = {0};
int i = 0;
int ch;
while ((ch = scc_probe_stream_consume(stream)) != core_stream_eof &&
while ((ch = scc_probe_stream_consume(stream)) != scc_stream_eof &&
i < 255) {
buffer[i++] = (char)ch;
}

View File

@@ -9,13 +9,13 @@ void check_skip_line(const char *str, const char *expect_remaining) {
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
lex_parse_skip_line(stream, &pos);
scc_lex_parse_skip_line(stream, &pos);
// Check remaining content
char buffer[256] = {0};
int i = 0;
int ch;
while ((ch = scc_probe_stream_consume(stream)) != core_stream_eof &&
while ((ch = scc_probe_stream_consume(stream)) != scc_stream_eof &&
i < 255) {
buffer[i++] = (char)ch;
}

View File

@@ -9,7 +9,7 @@ cbool check_string(const char *str, const char *expect, scc_cstring_t *output) {
scc_probe_stream_t *stream =
scc_mem_probe_stream_init(&mem_stream, str, scc_strlen(str), false);
cbool ret = lex_parse_string(stream, &pos, output);
cbool ret = scc_lex_parse_string(stream, &pos, output);
if (ret && expect) {
return strcmp(output->data, expect) == 0;
}