Trying to add order indendent decls

This commit is contained in:
Krzosa Karol
2022-05-26 21:09:07 +02:00
parent 0e398c84b6
commit b773ad1c17
5 changed files with 124 additions and 51 deletions

View File

@@ -144,7 +144,7 @@ parse_expr_compound(){
while(!token_is(TK_CloseBrace)){
Token *token = token_get();
Ast_Expr *index = 0;
Ast_Expr *name = 0;
Ast_Atom *name = 0;
if(token_match(TK_OpenBracket)){
index = parse_expr();
token_expect(TK_CloseBracket);
@@ -452,28 +452,4 @@ parse_named(B32 is_global){
return result;
}
function Ast_Package *
parse_file(){
Scratch scratch;
//
// @note: pop the first token with token_next() / token_expect()
// which always should be an indentation token,
// it updates the indent info on the parser,
// making sure that indentation on
// the first line is properly updated
//
Token *token = token_get();
Array<Ast_Named *>decls = {scratch};
while(!token_is(TK_End)){
token_expect(SAME_SCOPE);
Ast_Named *decl = parse_named(true);
if(!decl) break;
decls.add(decl);
}
Ast_Package *result = ast_package(token, token->file, decls);
return result;
}