Ast_Init is not Ast_Binary with TK_Comma
This commit is contained in:
@@ -135,14 +135,14 @@ Compound literals
|
||||
*/
|
||||
function Ast_Expr *parse_expr(S64 rbp = 0);
|
||||
|
||||
function Ast_Init *
|
||||
function Ast_Binary *
|
||||
parse_init_stmt(Ast_Expr *expr){
|
||||
Token *token = token_get();
|
||||
if(token_match(TK_Colon)){
|
||||
if(expr->kind != AST_IDENT) parsing_error(token, "Failed to parse init stmt, expected left of [:] to be a token of kind [Identifier]");
|
||||
if(token_match(TK_Assign)){
|
||||
Ast_Expr *value = parse_expr();
|
||||
Ast_Init *result = ast_init(token, TK_Comma, (Ast_Atom *)expr, value);
|
||||
Ast_Binary *result = (Ast_Binary *)ast_expr_binary((Ast_Atom *)expr, value, token);
|
||||
return result;
|
||||
}
|
||||
else not_implemented;
|
||||
@@ -213,7 +213,7 @@ parse_block(){
|
||||
else if(token_match_keyword(keyword_if)){
|
||||
Array<Ast_If_Node *> if_nodes = {scratch};
|
||||
Ast_Expr *expr = parse_expr();
|
||||
Ast_Init *init_val = parse_init_stmt(expr);
|
||||
Ast_Binary *init_val = parse_init_stmt(expr);
|
||||
if(init_val){
|
||||
if(token_match(TK_Comma)) expr = parse_expr();
|
||||
else expr = 0;
|
||||
|
||||
Reference in New Issue
Block a user