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:
@@ -9,7 +9,7 @@
|
||||
struct scc_probe_stream;
|
||||
typedef struct scc_probe_stream scc_probe_stream_t;
|
||||
|
||||
#define core_stream_eof (-1)
|
||||
#define scc_stream_eof (-1)
|
||||
|
||||
/**
|
||||
* @brief 带探针的流接口
|
||||
@@ -113,8 +113,8 @@ typedef struct scc_mem_probe_stream {
|
||||
* @return core_probe_stream_t* 成功返回流指针,失败返回NULL
|
||||
*/
|
||||
scc_probe_stream_t *scc_mem_probe_stream_init(scc_mem_probe_stream_t *stream,
|
||||
const char *data, usize length,
|
||||
cbool need_copy);
|
||||
const char *data, usize length,
|
||||
cbool need_copy);
|
||||
#endif
|
||||
|
||||
#endif /* __SMCC_CORE_PROBE_STREAM_H__ */
|
||||
|
||||
@@ -8,7 +8,7 @@ static int mem_probe_stream_consume(scc_probe_stream_t *_stream) {
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->curr_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
return scc_stream_eof;
|
||||
}
|
||||
|
||||
unsigned char ch = stream->data[stream->curr_pos++];
|
||||
@@ -24,7 +24,7 @@ static int mem_probe_stream_peek(scc_probe_stream_t *_stream) {
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->probe_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
return scc_stream_eof;
|
||||
}
|
||||
|
||||
// 只查看而不移动探针位置
|
||||
@@ -36,7 +36,7 @@ static int mem_probe_stream_next(scc_probe_stream_t *_stream) {
|
||||
scc_mem_probe_stream_t *stream = (scc_mem_probe_stream_t *)_stream;
|
||||
|
||||
if (stream->probe_pos >= stream->data_length) {
|
||||
return core_stream_eof;
|
||||
return scc_stream_eof;
|
||||
}
|
||||
|
||||
// 返回探针位置的字符,并将探针位置向前移动
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* @enum hp_entry_state_t
|
||||
* @brief 哈希表条目状态标识
|
||||
*/
|
||||
typedef enum scc_hashmap_entry_state {
|
||||
typedef enum scc_hashtable_entry_state {
|
||||
ENTRY_EMPTY, /**< 空槽位(从未使用过) */
|
||||
ENTRY_ACTIVE, /**< 有效条目(包含键值对) */
|
||||
ENTRY_TOMBSTONE /**< 墓碑标记(已删除条目) */
|
||||
@@ -118,7 +118,7 @@ typedef int (*scc_hashtable_iter_fn)(const void *key, void *value,
|
||||
* @param iter_func 迭代回调函数
|
||||
* @param context 用户上下文指针
|
||||
*/
|
||||
void scc_hashmap_foreach(scc_hashtable_t *ht, scc_hashtable_iter_fn iter_func,
|
||||
void *context);
|
||||
void scc_hashtable_foreach(scc_hashtable_t *ht, scc_hashtable_iter_fn iter_func,
|
||||
void *context);
|
||||
|
||||
#endif /* __SCC_HASHMAP_H__ */
|
||||
|
||||
@@ -142,12 +142,12 @@ void scc_hashtable_drop(scc_hashtable_t *ht) {
|
||||
ht->tombstone_count = 0;
|
||||
}
|
||||
|
||||
void scc_hashmap_foreach(scc_hashtable_t *ht, scc_hashtable_iter_fn iter_func,
|
||||
void *context) {
|
||||
void scc_hashtable_foreach(scc_hashtable_t *ht, scc_hashtable_iter_fn iter_func,
|
||||
void *context) {
|
||||
for (usize i = 0; i < ht->entries.cap; i++) {
|
||||
scc_hashtable_entry_t *entry = &scc_vec_at(ht->entries, i);
|
||||
if (entry->state == ENTRY_ACTIVE) {
|
||||
if (!iter_func(entry->key, entry->value, context)) {
|
||||
if (iter_func(entry->key, entry->value, context)) {
|
||||
break; // enable callback function terminal the iter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ void scc_strpool_drop(scc_strpool_t *pool) { scc_hashtable_drop(&pool->ht); }
|
||||
|
||||
void scc_strpool_foreach(scc_strpool_t *pool, scc_strpool_iter_fn iter_func,
|
||||
void *context) {
|
||||
scc_hashmap_foreach(&pool->ht, (scc_hashtable_iter_fn)iter_func, context);
|
||||
scc_hashtable_foreach(&pool->ht, (scc_hashtable_iter_fn)iter_func, context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user