Skip to content

Commit

Permalink
impl preprocessing parantheses
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Sep 8, 2024
1 parent 8813506 commit c83cdab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 9 additions & 0 deletions preprocessor/preprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,11 @@ int preprocessor_evaluate_unary(struct compile_process *compiler,
return res;
}

int preprocessor_evaluate_parentheses(struct compile_process *compiler,
struct preprocessor_node *node) {
return preprocessor_evaluate(compiler, node->paren_node.exp);
}

int preprocessor_evaluate(struct compile_process *compiler,
struct preprocessor_node *root_node) {
struct preprocessor_node *current = root_node;
Expand All @@ -1376,6 +1381,10 @@ int preprocessor_evaluate(struct compile_process *compiler,
case PREPROCESSOR_UNARY_NODE:
res = preprocessor_evaluate_unary(compiler, current);
break;

case PREPROCESSOR_PARENTHESES_NODE:
res = preprocessor_evaluate_parentheses(compiler, current);
break;
}

return res;
Expand Down
7 changes: 2 additions & 5 deletions test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#define ABC !1
#if ABC > 0
#error "ABC > 0"
#endif
#define ABC (1 + 2 * (9 - 3))

int main() { return !0; }
int main() { return ABC; }

0 comments on commit c83cdab

Please sign in to comment.