From 84d5421b39949e3bc2f32c09dc590296775188a8 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Wed, 31 Jan 2024 16:41:26 +0800 Subject: [PATCH] fix(chapi-ast-c): fix macro expansion declaration in C.g4 #24 The macro expansion declaration in C.g4 was not correctly defined. This commit fixes the issue by updating the grammar rules. --- chapi-ast-c/src/main/antlr/C.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapi-ast-c/src/main/antlr/C.g4 b/chapi-ast-c/src/main/antlr/C.g4 index 14af8d44..28774487 100644 --- a/chapi-ast-c/src/main/antlr/C.g4 +++ b/chapi-ast-c/src/main/antlr/C.g4 @@ -61,7 +61,7 @@ primaryExpression | '__builtin_offsetof' '(' typeName ',' unaryExpression ')' // for macro support | typeQualifier? (typeKeywords | Identifier | '==' | '!=') (Identifier | typeKeywords)* pointer? - | (directDeclarator | StringLiteral)+ + | StringLiteral? (directDeclarator | StringLiteral)+ | Ellipsis ; @@ -471,9 +471,9 @@ macroStatement singleLineMacroDeclaration : '#' include (StringLiteral | ('<' includeIdentifier '>' )) #includeDeclaration - | '#' macroKeywords expression* '#' macroKeywords identifierList? #macroExpansionDeclaration | '#' macroKeywords #defineDeclaration | '#' '#'? Identifier #macroCastDeclaration + | '#' macroKeywords expression* '#' macroKeywords identifierList? #macroExpansionDeclaration ; macroKeywords