Modify main to use the new print ast functionality
All checks were successful
Validate the build / validate-build (push) Successful in 26s
All checks were successful
Validate the build / validate-build (push) Successful in 26s
This commit is contained in:
parent
faaf4111bb
commit
0177d86054
11
src/main.c
11
src/main.c
@ -32,13 +32,20 @@ void print_text(tokenlist_t *list) {
|
||||
}
|
||||
}
|
||||
|
||||
void parse_ast(tokenlist_t *list) {
|
||||
void print_ast(tokenlist_t *list) {
|
||||
parse_result_t result = parse(list->head);
|
||||
if (result.err) {
|
||||
puts(result.err->message);
|
||||
error_free(result.err);
|
||||
return;
|
||||
}
|
||||
ast_node_print(result.node);
|
||||
|
||||
if (result.next != nullptr) {
|
||||
puts("First unparsed token:");
|
||||
lexer_token_print(&result.next->token);
|
||||
}
|
||||
|
||||
ast_node_free(result.node);
|
||||
}
|
||||
|
||||
@ -82,7 +89,7 @@ int main(int argc, char *argv[]) {
|
||||
print_text(list);
|
||||
break;
|
||||
case MODE_AST:
|
||||
parse_ast(list);
|
||||
print_ast(list);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user