@@ -35,8 +35,8 @@ grammar C;
35
35
36
36
compilationUnit
37
37
// statement for macro support
38
- : (externalDeclaration)* EOF
39
- // | (externalDeclaration | statement | macroPostixCall)* EOF
38
+ // : (externalDeclaration)* EOF
39
+ : (externalDeclaration | statement | macroPostixCall)* EOF
40
40
;
41
41
42
42
MultiLineMacro
@@ -489,42 +489,42 @@ logicals : logicalOrExpression (',' logicalOrExpression)* ;
489
489
Directive : ' #' ~ [\n]* -> channel (HIDDEN );
490
490
491
491
macroStatement
492
- // : '#' singleLineMacroDeclaration*
493
- : ' #' include (StringLiteral | Identifier | (' <' includeIdentifier ' >' )) #includeDeclaration
494
- ;
495
-
496
- // singleLineMacroDeclaration
497
- // : include (StringLiteral | Identifier | ('<' includeIdentifier '>' )) #includeDeclaration
498
- // | ('ifdef' | 'ifndef' | 'if') Identifier statement* ('#' 'else' statement*)? '#' 'endif'
499
- // #ifdefDeclaration
500
- // | 'define' Identifier defineMacro #defineDeclaration
501
- // // | macroKeywords (assignmentExpression)*
502
- // // ('#' macroKeywords)? identifierList? #macroDefineDeclaration
503
- // | '#'? Identifier #macroCastDeclaration
504
- // | macroKeywords macroFunctionExpression? #macroStatementDeclaration
505
- // ;
506
- //
507
- // defineMacro
508
- // : expressionStatement? #macroAssignDeclaration
509
- // | postixCall Identifier postixCall #macroAliasDeclaration
510
- // | structOrUnionSpecifier #macroStructureDeclaration
511
- // ;
512
- //
513
- //
514
- // macroFunctionExpression
515
- // : Identifier
516
- // | Identifier '(' ( parameterTypeList| (macroType (',' macroType)*) ) ')'
517
- // | assignmentExpression
518
- // ;
519
- //
520
- // macroType
521
- // : typeQualifier? (typeKeywords | Identifier | '==' | '!=' | comparator) (Identifier | typeKeywords)* pointer?
522
- // | expressionStatement
523
- // ;
524
- //
525
- // macroKeywords
526
- // : 'if' | 'undef' | 'else' | 'pragma' | 'endif' | 'ifdef' | 'ifndef' | 'elif' | 'define' | 'ifndef' | 'error'
527
- // ;
492
+ : ' #' singleLineMacroDeclaration*
493
+ // : '#' include (StringLiteral | Identifier | ('<' includeIdentifier '>' )) #includeDeclaration
494
+ ;
495
+
496
+ singleLineMacroDeclaration
497
+ : include (StringLiteral | Identifier | (' <' includeIdentifier ' >' )) #includeDeclaration
498
+ | (' ifdef' | ' ifndef' | ' if' ) Identifier statement* (' #' ' else' statement*)? ' #' ' endif'
499
+ #ifdefDeclaration
500
+ | ' define' Identifier defineMacro #defineDeclaration
501
+ // | macroKeywords (assignmentExpression)*
502
+ // ('#' macroKeywords)? identifierList? #macroDefineDeclaration
503
+ | ' #' ? Identifier #macroCastDeclaration
504
+ | macroKeywords macroFunctionExpression? #macroStatementDeclaration
505
+ ;
506
+
507
+ defineMacro
508
+ : expressionStatement? #macroAssignDeclaration
509
+ | postixCall Identifier postixCall #macroAliasDeclaration
510
+ | structOrUnionSpecifier #macroStructureDeclaration
511
+ ;
512
+
513
+
514
+ macroFunctionExpression
515
+ : Identifier
516
+ | Identifier ' (' ( parameterTypeList| (macroType (' ,' macroType)*) ) ' )'
517
+ | assignmentExpression
518
+ ;
519
+
520
+ macroType
521
+ : typeQualifier? (typeKeywords | Identifier | ' ==' | ' !=' | comparator) (Identifier | typeKeywords)* pointer?
522
+ | expressionStatement
523
+ ;
524
+
525
+ macroKeywords
526
+ : ' if' | ' undef' | ' else' | ' pragma' | ' endif' | ' ifdef' | ' ifndef' | ' elif' | ' define' | ' ifndef' | ' error'
527
+ ;
528
528
529
529
labeledStatement
530
530
: Identifier ' :' statement?
@@ -1023,15 +1023,6 @@ fragment Nondigit
1023
1023
: [a-zA-Z_ ]
1024
1024
;
1025
1025
1026
-
1027
- MacroId
1028
- : UpperedId (UpperedId)*
1029
- ;
1030
-
1031
- fragment UpperedId
1032
- : [A -Z_ ]
1033
- ;
1034
-
1035
1026
fragment Digit
1036
1027
: [0-9]
1037
1028
;
0 commit comments