diff --git a/new_ast.cpp b/new_ast.cpp index cd512e6..eb8b5cf 100644 --- a/new_ast.cpp +++ b/new_ast.cpp @@ -257,9 +257,8 @@ ast_expr_index(Token *pos, Ast_Expr *expr, Ast_Expr *index){ return result; } - function Ast_Lambda * -ast_lambda(Token *pos, Array params, Ast_Typespec *ret){ +ast_lambda(Token *pos, Array params, Ast_Typespec *ret, Ast_Block *block){ AST_NEW(Lambda, AST_LAMBDA, pos); result->args = params.tight_copy(pctx->perm); result->ret = ret; diff --git a/new_lex.cpp b/new_lex.cpp index d092b46..ba9786f 100644 --- a/new_lex.cpp +++ b/new_lex.cpp @@ -114,6 +114,7 @@ struct Lex_Stream{ String file; S32 line; S32 inside_brace_paren; + S32 last_valid_indent; }; struct Lexer{ @@ -481,7 +482,11 @@ lex__stream(Intern_Table *table, Array *array, Lex_Stream *s){ if(t.len==0) lex_set_len(s,&t); - B32 skip = t.kind == TK_NewLine && s->inside_brace_paren > 0; + B32 skip = 0; + if(t.kind == TK_NewLine){ + if(s->inside_brace_paren > 0) skip = 1; + if(array->len > 0 && array->last()->kind == TK_NewLine) array->pop(); + } if(!skip){ array->add(t); } diff --git a/new_parse.cpp b/new_parse.cpp index 4054c54..177d4aa 100644 --- a/new_parse.cpp +++ b/new_parse.cpp @@ -165,16 +165,16 @@ parse_optional_type(){ return result; } -/* -function Ast_Block * -parse_block(){ - Ast_Block *result = 0; - if(token_match(TK_NewScope)){ - } - return result; -} - */ +// function Ast_Block * +// parse_block(){ +// Ast_Block *result = 0; +// if(token_match(TK_NewScope)){ + +// } +// return result; +// } + function Ast_Lambda * parse_lambda(Token *token, B32 is_typespec = false){ // @Todo(Krzosa): is_typespec is not used currently @@ -197,8 +197,9 @@ parse_lambda(Token *token, B32 is_typespec = false){ // @Todo(Krzosa): is_typesp } token_expect(TK_CloseParen); - //Ast_Block *block = parse_block(); - Ast_Lambda *result = ast_lambda(token, params, parse_optional_type()); + Ast_Typespec *ret = parse_optional_type(); + Ast_Block *block = 0; + Ast_Lambda *result = ast_lambda(token, params, ret, block); return result; }