Skip to content

Commit

Permalink
feat(chapi-ast-c): add support for additional macro keyword in C.g4 #24
Browse files Browse the repository at this point in the history
Add support for the macro keyword 'ifdef' in the 'conditionalDeclaration' rule of the C.g4 file in chapi-ast-c/src/main/antlr. This allows for more comprehensive parsing of C code.
  • Loading branch information
phodal committed Jan 30, 2024
1 parent ad1780d commit 799a3f6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chapi-ast-c/src/main/antlr/C.g4
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ compilationUnit
oneLineMacroDeclaration
: '#' include (StringLiteral | ('<' includeIdentifier '>' )) #includeDeclaration
| '#' 'define' expression* #defineDeclaration
| '#'( 'if' | 'undef' | 'else' | 'pragma' | 'endif' ) expression* #conditionalDeclaration
| '#' macroKeywords expression* #conditionalDeclaration
| Identifier postixCall? compoundStatement? #macroCall
;

macroKeywords
: 'if' | 'undef' | 'else' | 'pragma' | 'endif' | 'ifdef'
;

MultiLineMacro
: '#' (~[\n]*? '\\' '\r'? '\n')+ ~ [\n]+ -> channel (HIDDEN)
;
Expand Down

0 comments on commit 799a3f6

Please # to comment.