移除了旧的lexer_stream.c实现,引入新的环形缓冲区机制来替代原有的 动态数组缓冲区。更新了词法分析器的核心数据结构,修改了token获取 相关函数的实现以支持新的缓冲区管理方式。 BREAKING CHANGE: 移除了scc_lexer_stream_t相关的API,替换为基于 环形缓冲区的新接口scc_lexer_to_ring和相关函数。 feat(lexer_token): 添加词法分析结果内存泄漏警告注释 docs: 移除预处理器模块的测试文件和相关配置
34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
#ifndef __SCC_SSTREAM_H__
|
|
#define __SCC_SSTREAM_H__
|
|
|
|
#include "scc_pos.h"
|
|
#include <scc_core.h>
|
|
#include <scc_core_ring.h>
|
|
|
|
typedef struct {
|
|
scc_pos_t pos;
|
|
int character;
|
|
} scc_sstream_char_t;
|
|
|
|
typedef SCC_RING(scc_sstream_char_t) scc_sstream_ring_t;
|
|
|
|
typedef struct {
|
|
const char *fname;
|
|
scc_pos_t pos; // 当前消费位置 (可选,可由 ring 推导)
|
|
int used; // 是否仍然在使用
|
|
int owned_src; // 是否拥有src内存 即是否需要释放
|
|
const char *src; // 文件内容缓冲区 (由 sstream 管理)
|
|
usize len; // 缓冲区长度
|
|
scc_pos_t fill_pos; // 内部填充位置
|
|
scc_sstream_ring_t ring;
|
|
} scc_sstream_t;
|
|
|
|
int scc_sstream_init(scc_sstream_t *stream, const char *fname, int ring_size);
|
|
int scc_sstream_init_by_buffer(scc_sstream_t *stream, const char *buffer,
|
|
usize len, int owned, int ring_size);
|
|
scc_sstream_ring_t *scc_sstream_to_ring(scc_sstream_t *stream);
|
|
void scc_sstream_drop_ring(scc_sstream_ring_t *ring);
|
|
void scc_sstream_drop(scc_sstream_t *stream);
|
|
|
|
#endif /* __SCC_SSTREAM_H__ */
|