Skip to content

Commit 2d2eecf

Browse files
committed
feat(c): add support for macro expansion declaration #24
Add support for a new macro expansion declaration in the C grammar. This allows for the definition and expansion of macros in the code.
1 parent 84d5421 commit 2d2eecf

File tree

1 file changed

+3
-1
lines changed
  • chapi-ast-c/src/main/antlr

1 file changed

+3
-1
lines changed

Diff for: chapi-ast-c/src/main/antlr/C.g4

+3-1
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,11 @@ macroStatement
471471

472472
singleLineMacroDeclaration
473473
: '#' include (StringLiteral | ('<' includeIdentifier '>' )) #includeDeclaration
474+
| '#' 'define' expression* '#' 'undef' identifierList? #macroExpansionDeclaration
475+
| '#' ('ifdef' | 'endif') Identifier expression* '#' 'endif' Identifier? #ifdefDeclaration
474476
| '#' macroKeywords #defineDeclaration
475477
| '#' '#'? Identifier #macroCastDeclaration
476-
| '#' macroKeywords expression* '#' macroKeywords identifierList? #macroExpansionDeclaration
478+
| '#' macroKeywords expression* '#' macroKeywords identifierList? #macroExpansionDeclaration2
477479
;
478480

479481
macroKeywords

0 commit comments

Comments
 (0)