Files
scc/libs/lexer/include/scc_lexer.h
zzy 31d7e91ef1 refactor(ast2ir): 重构ABI类型系统并修复union结构问题
- 将scc_ast_def.h中的attr_of从union改为struct以修复结构定义问题
- 添加type_abi依赖到ast2ir模块的cbuild.toml配置文件中
- 重命名scc_ast2ir.h中的abi字段为type_abi,并更新相关初始化函数签名
- 移除废弃的scc_abi_type.h和相关平台ABI头文件
- 添加辅助函数is_variadic_marker和fixed_param_count用于处理可变参数
- 添加数组和聚合类型初始化的辅助函数
2026-06-01 12:14:13 +08:00

57 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file lexer.h
* @brief C语言词法分析器核心数据结构与接口
*/
#ifndef __SCC_LEXER_H__
#define __SCC_LEXER_H__
#include "scc_lexer_token.h"
#include <scc_core.h>
#include <scc_core_ring.h>
#include <scc_sstream.h>
/**
* @brief 词法分析器核心结构体
*
* 封装词法分析所需的状态信息和缓冲区管理
*/
typedef struct scc_lexer {
scc_sstream_ring_t *stream_ref;
scc_lexer_tok_ring_t ring;
int ring_ref_count;
int jump_macro;
int max_token_len; /**< 最大 token 长度, 0=不限制 */
} scc_lexer_t;
void scc_lexer_init(scc_lexer_t *lexer, scc_sstream_ring_t *stream_ref);
/** @brief 设置最大 token 长度限制, 超过时报错。0=不限制(默认) */
void scc_lexer_set_max_token_len(scc_lexer_t *lexer, int max_len);
/**
* @brief 获取原始token
* @param[in] lexer 词法分析器实例
* @param[out] token 输出token存储位置
*
* 此函数会返回所有类型的token包括空白符等无效token
*/
void scc_lexer_get_token(scc_lexer_t *lexer, scc_lexer_tok_t *token);
/**
* @brief 获取有效token
* @param[in] lexer 词法分析器实例
* @param[out] token 输出token存储位置
*
* 此函数会自动跳过空白符等无效token返回对语法分析有意义的token
*/
void scc_lexer_get_valid_token(scc_lexer_t *lexer, scc_lexer_tok_t *token);
scc_lexer_tok_ring_t *scc_lexer_to_ring(scc_lexer_t *lexer, int ring_size,
cbool need_comment);
void scc_lexer_drop_ring(scc_lexer_tok_ring_t *ring_ref);
void scc_lexer_drop(scc_lexer_t *lexer);
#endif /* __SCC_LEXER_H__ */