-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/main'
- Loading branch information
Showing
9 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
include/frontend/parser/printer/nodes/statements/print_while.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef PRINT_WHILE_H | ||
#define PRINT_WHILE_H | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "frontend/ast/definitions.h" | ||
#include "frontend/parser/printer/print_indent.h" | ||
#include "frontend/parser/printer/print_ast.h" | ||
#include "frontend/parser/printer/visited.h" | ||
|
||
void print_while(const AstNode *node, int depth, VisitedNodes *visited); | ||
|
||
#endif // PRINT_WHILE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/frontend/parser/printer/nodes/statements/print_while.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "frontend/parser/printer/nodes/statements/print_while.h" | ||
|
||
void print_while(const AstNode *node, int depth, VisitedNodes *visited) { | ||
if (!node || node->kind != NODE_WHILE) return; | ||
|
||
WhileNode *while_data = (WhileNode *)node->data; | ||
|
||
print_indent(depth + 1); | ||
if (while_data->condition) { | ||
print_ast_node(while_data->condition, depth + 2, visited); | ||
} else { | ||
print_indent(depth + 2); | ||
printf("Condition: <NULL>\n"); | ||
} | ||
|
||
if (while_data->body_count > 0) { | ||
print_indent(depth + 1); | ||
printf("Body: \n"); | ||
|
||
for (size_t i = 0; i < while_data->body_count; i++) { | ||
print_ast_node(while_data->body[i], depth + 2, visited); | ||
} | ||
} else { | ||
print_indent(depth + 1); | ||
printf("Body: <NULL>\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters