Commit Graph

5 Commits

Author SHA1 Message Date
zzy
09f4ac8de0 feat(lex_parser, pprocessor): replace consume with next and remove stream resets
- Replace `scc_probe_stream_consume` with `scc_probe_stream_next` for consistent stream advancement
- Remove redundant `scc_probe_stream_reset` calls before peeking, as `next` and `peek` handle state
- Update `scc_cstring_new` to `scc_cstring_create` and `scc_pos_init` to `scc_pos_create` for naming consistency
- Change `scc_pp_macro_get` parameter to `const scc_cstring_t*` for better const-correctness
- Improves code clarity and maintains proper stream position tracking
2025-12-28 10:49:29 +08:00
zzy
73d74f5e13 refactor(pprocessor): rename macro table type and update function names
- Change `scc_macro_table_t` to `scc_pp_macro_table_t` for consistency
- Rename `scc_pp_macro_create` to `scc_pp_macro_new` for naming convention
- Remove unused `scc_pp_compress_whitespace` function
- Update macro table function names: `scc_pp_find_macro` → `scc_pp_macro_table_get`, `scc_pp_remove_macro` → `scc_pp_macro_table_remove`
- Add new `scc_pp_macro_table_set` function for setting macros
- Update all function signatures to use new type name
- Remove commented-out whitespace compression code from implementation
2025-12-14 12:59:03 +08:00
zzy
ce8031b21f feat(parse): implement # and ## operator handling in macro expansion
- Add support for # (stringify) and ## (concatenation) operators in macro replacement lists
- Implement scc_pp_expand_string_unsafe() to process operator tokens during macro expansion
- Add helper macros to identify blank, stringify, and concatenation tokens in replacement lists
- Include missing headers (ctype.h, string.h) for character handling functions
- Update object macro expansion to use new string expansion function instead of simple concatenation
- Improve whitespace handling in macro replacement parsing to prevent interference with operator processing
2025-12-13 18:29:21 +08:00
zzy
07a76d82f4 feat(lex_parser, pprocessor): rename identifier header check and add macro system
- Rename `scc_lex_parse_is_identifier_header` to `scc_lex_parse_is_identifier_prefix` for clarity and add a TODO comment
- Update lexer to use the renamed function for consistency
- Fix package and dependency names in `cbuild.toml` (`smcc_pprocesser` → `scc_pprocesser`, `smcc_lex_parser` → `lex_parser`)
- Introduce new macro system with header file `pp_macro.h` defining macro types, structures, and management functions
- Refactor preprocessor initialization and cleanup in `pprocessor.c` to use new macro table and stream handling
- Replace legacy `hashmap` with `scc_pp_macro_table_t` for macro storage
- Improve error handling and resource management in preprocessor lifecycle
2025-12-13 16:09:46 +08:00
zzy
e6a76e7a86 feat(lex_parser): 提取字符判断函数并增强解析器断言
将 `is_next_line` 内联函数重命名为 `lex_parse_is_endline` 并新增 `lex_parse_is_whitespace` 函数,统一用于词法解析中的字符分类。同时加强多个解析函数的输入参数断言,提升代码健壮性。

此外,修正了 `lex_parse_skip_whitespace` 中的逻辑错误,并优化部分注释和控制流结构。

feat(pprocessor): 初始化预处理器模块并添加基础功能实现

新增预处理器模块 `pprocessor`,包括宏定义、条件编译状态管理以及基本的指令解析框架。实现了标识符解析、空白跳过、关键字查找等功能,并初步支持 `#define` 指令的对象类宏替换。

该提交还引入了一组测试用例,覆盖多种宏展开场景及边界情况,确保预处理器的核心行为符合预期。
2025-11-24 22:44:08 +08:00