Fix big casting bug in CALL, euler.kl is working now too
This commit is contained in:
26
parsing.cpp
26
parsing.cpp
@@ -183,14 +183,14 @@ parse_optional_type(){
|
||||
}
|
||||
|
||||
function Ast_Scope *
|
||||
parse_stmt_scope(){
|
||||
Ast_Scope *scope = 0;
|
||||
parse_stmt_scope(Ast_Scope *scope_defined_outside = 0){
|
||||
Ast_Scope *scope = scope_defined_outside;
|
||||
|
||||
if(token_expect(OPEN_SCOPE)){ // @todo: Fix error message here, it doesn't show proper token context
|
||||
Token *token_block = token_get();
|
||||
|
||||
Scratch scratch;
|
||||
scope = begin_stmt_scope(scratch, token_block);
|
||||
if(!scope_defined_outside) scope = begin_stmt_scope(scratch, token_block);
|
||||
do{
|
||||
Token *token = token_get();
|
||||
if(token_match_keyword(keyword_return)){
|
||||
@@ -204,6 +204,7 @@ parse_stmt_scope(){
|
||||
}
|
||||
|
||||
else if(token_match_keyword(keyword_for)){
|
||||
Ast_Scope *for_scope = begin_stmt_scope(scratch, token_get());
|
||||
Ast_Expr *init = 0;
|
||||
Ast_Expr *cond = 0;
|
||||
Ast_Expr *iter = 0;
|
||||
@@ -224,8 +225,9 @@ parse_stmt_scope(){
|
||||
}
|
||||
}
|
||||
|
||||
Ast_Scope *for_block = parse_stmt_scope();
|
||||
scope->stmts.add(ast_for(token, init, cond, iter, for_block));
|
||||
parse_stmt_scope(for_scope);
|
||||
finalize_stmt_scope(for_scope);
|
||||
scope->stmts.add(ast_for(token, init, cond, iter, for_scope));
|
||||
}
|
||||
|
||||
else if(token_match_keyword(keyword_if)){
|
||||
@@ -281,7 +283,7 @@ parse_stmt_scope(){
|
||||
} while(token_match(SAME_SCOPE));
|
||||
token_expect(CLOSE_SCOPE);
|
||||
|
||||
finalize_stmt_scope(scope);
|
||||
if(!scope_defined_outside) finalize_stmt_scope(scope);
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
@@ -318,10 +320,11 @@ parse_lambda(Token *token){
|
||||
}
|
||||
}
|
||||
token_expect(TK_CloseParen);
|
||||
|
||||
Ast_Expr *ret = parse_optional_type();
|
||||
Ast_Expr *ret = parse_optional_type();
|
||||
Token *foreign = token_match(TK_FOREIGN);
|
||||
Ast_Scope *scope = token_is(OPEN_SCOPE) ? parse_stmt_scope() : 0;
|
||||
Ast_Lambda *result = ast_lambda(token, params, ret, scope);
|
||||
if(foreign) set_flag(result->flags, AST_FOREIGN);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -508,7 +511,6 @@ function Ast_Decl *
|
||||
parse_struct(Token *pos){
|
||||
Scratch scratch;
|
||||
|
||||
|
||||
token_match(OPEN_SCOPE);
|
||||
Ast_Scope *scope = begin_decl_scope(scratch, token_get());
|
||||
do{
|
||||
@@ -565,11 +567,6 @@ parse_decl(B32 is_global){
|
||||
}
|
||||
}
|
||||
|
||||
Ast_Flag flags = 0;
|
||||
if(token_match(TK_FOREIGN)){
|
||||
flags = set_flag(flags, AST_FOREIGN);
|
||||
}
|
||||
|
||||
Token *tname = token_get();
|
||||
if(token_match(TK_Identifier, TK_DoubleColon)){
|
||||
// @note parse struct binding
|
||||
@@ -610,7 +607,6 @@ parse_decl(B32 is_global){
|
||||
|
||||
if(result){
|
||||
result->name = tname->intern_val;
|
||||
result->flags = set_flag(result->flags, flags);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user