Fix crashes
This commit is contained in:
@@ -27,6 +27,7 @@ array2: [32]int = {1,2,3,4}
|
||||
array3: [32]int = {
|
||||
[0] = null,
|
||||
[1] = 1,
|
||||
[2] = 2,
|
||||
[31] = 31,
|
||||
}
|
||||
array_item := array1[0]
|
||||
|
||||
4
main.cpp
4
main.cpp
@@ -23,8 +23,8 @@ int main(){
|
||||
test_intern_table();
|
||||
lex_test();
|
||||
|
||||
// String result = compile_file("globals.kl"_s);
|
||||
String result = compile_file("lambdas.kl"_s);
|
||||
String result = compile_file("globals.kl"_s);
|
||||
// String result = compile_file("lambdas.kl"_s);
|
||||
// String result = compile_file("order_independent_globals.kl"_s);
|
||||
printf("%s", result.str);
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ ast_expr_compound(Token *pos, Ast_Expr *typespec, Array<Ast_Compound_Item *> exp
|
||||
AST_NEW(Compound, COMPOUND, pos);
|
||||
result->typespec = typespec;
|
||||
result->exprs = exprs.tight_copy(pctx->perm);
|
||||
result->typespec->parent = result;
|
||||
if(result->typespec) result->typespec->parent = result;
|
||||
For(result->exprs) it[0]->parent = result;
|
||||
return result;
|
||||
}
|
||||
@@ -287,8 +287,8 @@ ast_expr_compound_item(Token *pos, Ast_Expr *index, Ast_Atom *name, Ast_Expr *it
|
||||
result->name = name;
|
||||
result->index = index;
|
||||
result->item = item;
|
||||
name->parent = result;
|
||||
index->parent = result;
|
||||
if(result->name) result->name->parent = result;
|
||||
if(result->index) result->index->parent = result;
|
||||
item->parent = result;
|
||||
return result;
|
||||
}
|
||||
@@ -330,7 +330,7 @@ ast_lambda(Token *pos, Array<Ast_Lambda_Arg *> params, Ast_Expr *ret, Ast_Block
|
||||
result->ret = ret;
|
||||
if(!ret) result->ret = ast_ident(result->pos, intern_void);
|
||||
|
||||
result->block->parent = result;
|
||||
if(result->block) result->block->parent = result;
|
||||
result->ret->parent = result;
|
||||
For(result->args) it[0]->parent = result;
|
||||
return result;
|
||||
|
||||
@@ -121,7 +121,6 @@ struct Lex_Stream{
|
||||
String file;
|
||||
S32 line;
|
||||
S32 inside_brace_paren;
|
||||
S32 last_valid_indent;
|
||||
Array<Token *> indent_stack;
|
||||
};
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ parse_expr_compound(){
|
||||
Scratch scratch;
|
||||
Token *pos = token_get();
|
||||
Array<Ast_Compound_Item *> exprs = {scratch};
|
||||
|
||||
while(!token_is(TK_CloseBrace)){
|
||||
Token *token = token_get();
|
||||
Ast_Expr *index = 0;
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
|
||||
/*
|
||||
@todo: !!!
|
||||
Maybe instead of compound exprs like this:
|
||||
[4]Thing{1,2,3,4}
|
||||
|
||||
Do it like this
|
||||
[4]Thing(1,2,3,4)
|
||||
[4]Thing([0]=1, [3]=3)
|
||||
Thing(a=1, b=2)
|
||||
|
||||
unifying the call expression and compound expression
|
||||
seems more unified and better for coherence
|
||||
but more abigous and probably harder to implement
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
other_func :: ()
|
||||
a_val := recursive_lambda
|
||||
|
||||
Reference in New Issue
Block a user