Core: Add Ast_Label

This commit is contained in:
Krzosa Karol
2023-04-22 12:38:48 +02:00
parent d244608571
commit eff6b10cf4
10 changed files with 140 additions and 98 deletions

View File

@@ -293,7 +293,7 @@ parse_stmt_scope(Ast_Scope *scope_defined_outside = 0) {
scope->stmts.add(ast_continue(token));
}
else if (token_match_keyword(pctx->keyword___compilerbreakpoint)) {
else if (token_match_keyword(pctx->intern_compiler_breakpoint)) {
scope->stmts.add(ast_compiler_breakpoint(token));
}
@@ -423,6 +423,21 @@ parse_stmt_scope(Ast_Scope *scope_defined_outside = 0) {
scope->stmts.add(result_if);
}
// Label
else if (token_match(TK_Colon)) {
Token *ident = token_expect(TK_Identifier);
Token *enable_goto_token = token_match(TK_Colon);
bool enable_goto = enable_goto_token ? 1 : 0;
Token *breakpoint = token_match_pound(pctx->intern_compiler_breakpoint);
Ast_Scope *s = 0;
if (token_is(OPEN_SCOPE)) s = parse_stmt_scope();
Ast_Label *result = ast_label(token, ident->intern_val, s, enable_goto);
if (breakpoint) set_flag(result->flags, AST_COMPILER_BREAKPOINT);
scope->stmts.add(result);
}
// Var unpack
else if (token_is(TK_Identifier) && token_is(TK_Comma, 1)) {
Array<Ast_Decl *> decls = {scratch.arena};