feat(build): 引入新的 Python 构建系统并移除旧 Makefile
新增基于 Python 的构建脚本 `cbuild.py`,支持包管理、依赖解析和模块化编译。 同时添加 `.gitignore` 忽略 `build` 目录,并在 `justfile` 中更新构建命令。 移除了原有的 `lib/Makefile` 和主目录下的相关 make 规则,统一使用新构建系统。
This commit is contained in:
62
libs/lexer/include/lexer.h
Normal file
62
libs/lexer/include/lexer.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @file lexer.h
|
||||
* @brief C语言词法分析器核心数据结构与接口
|
||||
*/
|
||||
|
||||
#ifndef __SMCC_CC_LEXER_H__
|
||||
#define __SMCC_CC_LEXER_H__
|
||||
|
||||
#include <libcore.h>
|
||||
#include "lexer_stream.h"
|
||||
#include "lexer_token.h"
|
||||
|
||||
typedef struct lexer_loc {
|
||||
const char *name;
|
||||
usize name_len;
|
||||
usize line;
|
||||
usize column;
|
||||
usize offset;
|
||||
} lexer_loc_t;
|
||||
|
||||
typedef struct lexer_token {
|
||||
token_type_t type;
|
||||
core_cvalue_t value;
|
||||
lexer_loc_t loc;
|
||||
} lexer_tok_t;
|
||||
|
||||
/**
|
||||
* @brief 词法分析器核心结构体
|
||||
*
|
||||
* 封装词法分析所需的状态信息和缓冲区管理
|
||||
*/
|
||||
typedef struct cc_lexer {
|
||||
lexer_stream_t* stream;
|
||||
lexer_loc_t pos;
|
||||
} smcc_lexer_t;
|
||||
|
||||
/**
|
||||
* @brief 初始化词法分析器
|
||||
* @param[out] lexer 要初始化的词法分析器实例
|
||||
* @param[in] stream 输入流对象指针
|
||||
*/
|
||||
void lexer_init(smcc_lexer_t* lexer, lexer_stream_t* stream);
|
||||
|
||||
/**
|
||||
* @brief 获取原始token
|
||||
* @param[in] lexer 词法分析器实例
|
||||
* @param[out] token 输出token存储位置
|
||||
*
|
||||
* 此函数会返回所有类型的token,包括空白符等无效token
|
||||
*/
|
||||
void lexer_get_token(smcc_lexer_t* lexer, lexer_tok_t* token);
|
||||
|
||||
/**
|
||||
* @brief 获取有效token
|
||||
* @param[in] lexer 词法分析器实例
|
||||
* @param[out] token 输出token存储位置
|
||||
*
|
||||
* 此函数会自动跳过空白符等无效token,返回对语法分析有意义的token
|
||||
*/
|
||||
void lexer_get_valid_token(smcc_lexer_t* lexer, lexer_tok_t* token);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user