diff options
Diffstat (limited to 'src/pipac.c')
-rw-r--r-- | src/pipac.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pipac.c b/src/pipac.c index 41294c4..2b7b1f5 100644 --- a/src/pipac.c +++ b/src/pipac.c @@ -47,6 +47,20 @@ print_tokens(lexer_t *lexer) { } } +void +parser_print_errors(parser_t *parser) { + for (int i=0; i < parser->errors_len; i++) { + parser_error_t error = parser->errors[i]; + + fprintf( + stderr, + "%s:%d:%d: [ERROR]: %s\n", + error.token.filepath, error.token.row + 1, error.token.col + 1, + error.message + ); + } +} + int main(int argc, char **argv) { @@ -64,7 +78,11 @@ main(int argc, char **argv) parser_init(&parser, &lexer); ast_node_t* func = ast_node_new(); - parser_parse_function_declaration(&parser, func); + + if (!parser_parse_function_declaration(&parser, func)) { + parser_print_errors(&parser); + return EXIT_FAILURE; + } generate_gas_x86_64_linux(func); |