Skip to content

Commit

Permalink
feat(c): add support for macro alias declaration #24
Browse files Browse the repository at this point in the history
This commit adds support for macro alias declaration in the chapi-ast-c file. The macroFunctionExpression rule has been modified to allow for parameterTypeList and expressionStatement.
  • Loading branch information
phodal committed Jan 31, 2024
1 parent 0ba7673 commit 8744a9d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chapi-ast-c/src/main/antlr/C.g4
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,19 @@ macroStatement
singleLineMacroDeclaration
: include (StringLiteral | Identifier | ('<' includeIdentifier '>' )) #includeDeclaration
| macroKeywords Identifier structOrUnionSpecifier #macroStructureDeclaration
| 'define' expressionStatement macroFunctionExpression #macroAliasDeclaration
| macroKeywords (expressionStatement)*
('#' macroKeywords)? identifierList? #macroDefineDeclaration
| 'define' macroFunctionExpression macroFunctionExpression #macroAliasDeclaration
| '#'? Identifier #macroCastDeclaration
;

macroFunctionExpression
: Identifier '(' (macroFunctionExpression | macroType | expression | macroKeywords)* ')'
: Identifier '(' ( parameterTypeList| (macroType (',' macroType)*) ) ')'
;

macroType
: typeQualifier? (typeKeywords | Identifier | '==' | '!=' | comparator) (Identifier | typeKeywords)* pointer?
| expressionStatement
;


Expand Down

0 comments on commit 8744a9d

Please sign in to comment.