Files
scc/libs/lexer/include/lexer.h
zzy 874a58281f 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
2025-12-13 14:06:13 +08:00

54 lines
1.3 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 "lexer_token.h"
#include <libcore.h>
typedef struct scc_lexer_token {
scc_tok_type_t type;
scc_cvalue_t value;
scc_pos_t loc;
} scc_lexer_tok_t;
/**
* @brief 词法分析器核心结构体
*
* 封装词法分析所需的状态信息和缓冲区管理
*/
typedef struct cc_lexer {
scc_probe_stream_t *stream;
scc_pos_t pos;
} scc_lexer_t;
/**
* @brief 初始化词法分析器
* @param[out] lexer 要初始化的词法分析器实例
* @param[in] stream 输入流对象指针
*/
void scc_lexer_init(scc_lexer_t *lexer, scc_probe_stream_t *stream);
/**
* @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);
#endif /* __SCC_LEXER_H__ */