feat(lex_parser): 提取字符判断函数并增强解析器断言
将 `is_next_line` 内联函数重命名为 `lex_parse_is_endline` 并新增 `lex_parse_is_whitespace` 函数,统一用于词法解析中的字符分类。同时加强多个解析函数的输入参数断言,提升代码健壮性。 此外,修正了 `lex_parse_skip_whitespace` 中的逻辑错误,并优化部分注释和控制流结构。 feat(pprocessor): 初始化预处理器模块并添加基础功能实现 新增预处理器模块 `pprocessor`,包括宏定义、条件编译状态管理以及基本的指令解析框架。实现了标识符解析、空白跳过、关键字查找等功能,并初步支持 `#define` 指令的对象类宏替换。 该提交还引入了一组测试用例,覆盖多种宏展开场景及边界情况,确保预处理器的核心行为符合预期。
This commit is contained in:
30
libs/pprocessor/tests/pp/18.c
Normal file
30
libs/pprocessor/tests/pp/18.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#define M_RETI_ARG27(x,y,z,aa, ...) aa
|
||||
#define M_RET_ARG27(...) M_RETI_ARG27(__VA_ARGS__)
|
||||
#define M_COMMA_P(...) M_RET_ARG27(__VA_ARGS__, 1, 1, 0, useless)
|
||||
#define M_EMPTYI_DETECT(...) 0, 1,
|
||||
#define M_EMPTYI_P_C1(...) M_COMMA_P(M_EMPTYI_DETECT __VA_ARGS__ () )
|
||||
#define EX
|
||||
#define empty(x)
|
||||
#define fnlike(x) yeah x
|
||||
/* If the following macro is called with empty arg (X183), the use
|
||||
of 'x' between fnlike and '(' doesn't hinder the recognition of this
|
||||
being a further fnlike macro invocation. */
|
||||
#define usefnlike(x) fnlike x (x)
|
||||
X181 M_EMPTYI_P_C1()
|
||||
X182 M_EMPTYI_P_C1(x)
|
||||
X183 usefnlike()
|
||||
|
||||
#define ABC(x) ABC : x
|
||||
#define A(a,b,c) a ## b ## c
|
||||
#define B(a,b,c) A(a,b,c)
|
||||
#define C(a,b,c) a b c
|
||||
B(
|
||||
C(A,C(,,),),
|
||||
C(B(,,),B,B(,,)),
|
||||
C(B(,,),B(,,),C)
|
||||
)/* */(a b c)
|
||||
|
||||
#define TEST(x) TEST : x
|
||||
#define K(a,b) a ## b
|
||||
#define L(a,b) K( TE a , b ST )
|
||||
L(,)(t e s t)
|
||||
Reference in New Issue
Block a user