Can call the compiler from command line with argument

This commit is contained in:
Krzosa Karol
2022-06-07 15:27:18 +02:00
parent 1a67fe3402
commit 44d26d6939
6 changed files with 40 additions and 18 deletions

View File

@@ -5,12 +5,12 @@ parsing_error(Token *token, const char *str, ...){
STRING_FMT(scratch, str, string);
// @Note(Krzosa): Print nice error message
printf("\nError: %s", string.str);
printf("\nError :: %s", string.str);
if(token){
if(token->kind == TK_Error){
printf("Token Error: %.*s", (int)token->error_val.len, token->error_val.str);
}
printf(" %s:%d\n", token->file.str, (S32)token->line + 1);
printf(" :: %s:%d\n", token->file.str, (S32)token->line + 1);
// @Note(Krzosa): Print error line
{
@@ -409,7 +409,11 @@ parse_expr(S64 min_bp){
case TK_Decrement : left = ast_expr_unary(token, TK_Decrement, parse_expr(prefix_bp.right)); break;
case TK_OpenBracket: {
Ast_Array *result = ast_array(token, parse_expr(0));
Ast_Expr *expr = 0;
if(!token_is(TK_CloseBracket))
expr = parse_expr(0);
Ast_Array *result = ast_array(token, expr);
token_expect(TK_CloseBracket);
result->base = parse_expr(prefix_bp.right);
left = result;