AST_STRICT for type aliases

This commit is contained in:
Krzosa Karol
2022-06-12 13:09:37 +02:00
parent beb10d6e2d
commit cd29798c1d
5 changed files with 19 additions and 10 deletions

View File

@@ -80,10 +80,10 @@ token_is_keyword(Intern_String keyword, S64 lookahead = 0){
}
function Token *
token_match_pound(String string){
token_match_pound(Intern_String string){
Token *token = token_get();
if(token->kind == TK_Pound){
if(string_compare(token->intern_val.s, string)){
if(token->intern_val == string){
return token_next();
}
}
@@ -340,11 +340,8 @@ parse_lambda(Token *token){
}
token_expect(TK_CloseParen);
Ast_Expr *ret = parse_optional_type();
Token *foreign = token_match_pound("foreign"_s);
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;
}
@@ -598,8 +595,16 @@ parse_decl(B32 is_global){
}
}
Ast_Flag flags = 0;
Token *tname = token_get();
if(token_match(TK_Identifier, TK_DoubleColon)){
if(token_match_pound(intern_strict)){
set_flag(flags, AST_STRICT);
} else if(token_match_pound(intern_foreign)){
set_flag(flags, AST_FOREIGN);
}
// @note parse struct binding
if(token_match_keyword(keyword_struct)){
result = parse_struct(tname);
@@ -638,6 +643,7 @@ parse_decl(B32 is_global){
if(result){
result->name = tname->intern_val;
set_flag(result->flags, flags);
}
return result;