-
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.
Ternary expresisons parsing fully implemented (#54 from wesuRage/main)
Ternary expresisons parsing fully implemented
- Loading branch information
Showing
11 changed files
with
268 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
def my_return( int i) -> int: | ||
return i; | ||
end; | ||
|
||
def main( ) -> int: | ||
return my_return( 10) ; | ||
end; | ||
bool isBigger := 3 > 2 ? 1 : 0; |
9 changes: 9 additions & 0 deletions
9
include/frontend/parser/printer/nodes/expressions/print_ternary.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,9 @@ | ||
#ifndef PRINT_TERNARY_H | ||
#define PRINT_TERNARY_H | ||
|
||
#include "frontend/ast/definitions.h" | ||
#include "frontend/parser/printer/visited.h" | ||
|
||
void print_ternary(const AstNode *node, int depth, VisitedNodes *visited); | ||
|
||
#endif // PRINT_TERNARY_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
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
21 changes: 21 additions & 0 deletions
21
src/frontend/parser/printer/nodes/expressions/print_ternary.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,21 @@ | ||
#include "frontend/parser/printer/nodes/expressions/print_ternary.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_ternary(const AstNode *node, int depth, VisitedNodes *visited){ | ||
TernaryNode *ternary_data = (TernaryNode *)node->data; | ||
|
||
print_indent(depth + 1); | ||
printf("Condition:\n"); | ||
print_ast_node(ternary_data->condition, depth + 2, visited); | ||
|
||
print_indent(depth + 1); | ||
printf("Consequent:\n"); | ||
print_ast_node(ternary_data->consequent, depth + 2, visited); | ||
|
||
print_indent(depth + 1); | ||
printf("Alternate:\n"); | ||
print_ast_node(ternary_data->alternate, depth + 2, visited); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
*/ | ||
void print_indent(int depth) { | ||
for (int i = 0; i < depth; i++) { | ||
printf(" "); | ||
printf(" "); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.