Skip to content

Commit

Permalink
fix(chapi-ast-c): modify C.g4 to support multiple macro declarations #24
Browse files Browse the repository at this point in the history


The C.g4 file in chapi-ast-c was modified to support multiple macro declarations. The previous implementation only allowed for a single declaration, but now it supports multiple declarations separated by StringLiterals or singleLineMacroDeclarations. This change improves the flexibility and functionality of the C.g4 file.
  • Loading branch information
phodal committed Jan 30, 2024
1 parent dae101f commit df1d26f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chapi-ast-c/src/main/antlr/C.g4
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ primaryExpression
| '__builtin_offsetof' '(' typeName ',' unaryExpression ')'
// for macro support
| (typeKeywords | Identifier | '==' | '!=') (Identifier | typeKeywords )* pointer?
| StringLiteral singleLineMacroDeclaration (singleLineMacroDeclaration | StringLiteral)*
| (singleLineMacroDeclaration | StringLiteral)+
| Ellipsis
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ typedef struct {
#endif
size_t n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
const char filename_prefix[] = TEST_PREFIX ".";
""".trimIndent()

val codeFile = CAnalyser().analysis(code, "helloworld.c")
Expand Down

0 comments on commit df1d26f

Please sign in to comment.