From 924fcdbb94f6863688b8a31601fac0170414fb71 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Wed, 31 Jan 2024 15:29:25 +0800 Subject: [PATCH] feat(c): refactor support for macro expansion #24 Add support for macro expansion in the C grammar by introducing a new rule `macroExpandDeclaration` in the `C.g4` file. This allows for more flexible macro usage in the code. --- chapi-ast-c/src/main/antlr/C.g4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chapi-ast-c/src/main/antlr/C.g4 b/chapi-ast-c/src/main/antlr/C.g4 index cfe83296..aacfa413 100644 --- a/chapi-ast-c/src/main/antlr/C.g4 +++ b/chapi-ast-c/src/main/antlr/C.g4 @@ -474,7 +474,8 @@ macroStatement singleLineMacroDeclaration : '#' include (StringLiteral | ('<' includeIdentifier '>' )) #includeDeclaration - | '#' macroKeywords expression* #defineDeclaration + | '#' macroKeywords expression* '#' macroKeywords identifierList? #macroExpansionDeclaration + | '#' macroKeywords #defineDeclaration | '#' '#'? Identifier #macroCastDeclaration ;