CORE_Static
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
function Ast_Decl *parse_decl(B32 is_global);
|
||||
CORE_Static Ast_Decl *parse_decl(B32 is_global);
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
print_token_line(Token *token){
|
||||
if(!token) return;
|
||||
|
||||
@@ -23,14 +23,14 @@ print_token_line(Token *token){
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
print_token_context(Token *token){
|
||||
if(!token) return;
|
||||
printf("\n");
|
||||
print_token_line(token);
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
compiler_error(Token *token1, Token *token2, const char *str, ...){
|
||||
Scratch scratch;
|
||||
STRING_FMT(scratch, str, string);
|
||||
@@ -56,7 +56,7 @@ compiler_error(Token *token1, Token *token2, const char *str, ...){
|
||||
Breakpoint;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
compiler_error(Token *token, const char *str, ...){
|
||||
Scratch scratch;
|
||||
STRING_FMT(scratch, str, string);
|
||||
@@ -75,7 +75,7 @@ compiler_error(Token *token, const char *str, ...){
|
||||
Breakpoint;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_get(S64 i = 0){
|
||||
i += pctx->token_iter;
|
||||
if(i >= pctx->tokens.len){
|
||||
@@ -85,14 +85,14 @@ token_get(S64 i = 0){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_is_scope(){
|
||||
Token *token = token_get();
|
||||
if(lex_is_scope(token)) return token;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_next(){
|
||||
Token *token = token_get();
|
||||
if(lex_is_scope(token)) pctx->indent = token->indent;
|
||||
@@ -100,7 +100,7 @@ token_next(){
|
||||
return token;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_is(Token_Kind kind, S64 lookahead = 0){
|
||||
Token *token = token_get(lookahead);
|
||||
if(token->kind == kind){
|
||||
@@ -109,7 +109,7 @@ token_is(Token_Kind kind, S64 lookahead = 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_is_keyword(Intern_String keyword, S64 lookahead = 0){
|
||||
Token *token = token_get(lookahead);
|
||||
if(token->kind == TK_Keyword){
|
||||
@@ -120,7 +120,7 @@ token_is_keyword(Intern_String keyword, S64 lookahead = 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_match_pound(Intern_String string){
|
||||
Token *token = token_get();
|
||||
if(token->kind == TK_Pound){
|
||||
@@ -131,7 +131,7 @@ token_match_pound(Intern_String string){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_match(Token_Kind kind){
|
||||
Token *token = token_get();
|
||||
if(token->kind == kind){
|
||||
@@ -140,7 +140,7 @@ token_match(Token_Kind kind){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_match(Token_Kind a, Token_Kind b){
|
||||
Token *ta = token_get();
|
||||
Token *tb = token_get(1);
|
||||
@@ -151,7 +151,7 @@ token_match(Token_Kind a, Token_Kind b){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_match_keyword(Intern_String string){
|
||||
Token *token = token_get();
|
||||
if(token->kind == TK_Keyword){
|
||||
@@ -163,7 +163,7 @@ token_match_keyword(Intern_String string){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Token *
|
||||
CORE_Static Token *
|
||||
token_expect(Token_Kind kind){
|
||||
Token *token = token_get();
|
||||
if(token->kind == kind) return token_next();
|
||||
@@ -171,7 +171,7 @@ token_expect(Token_Kind kind){
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Ast_Expr *
|
||||
CORE_Static Ast_Expr *
|
||||
parse_init_stmt(Ast_Expr *expr){
|
||||
Token *token = token_get();
|
||||
if(token->kind == TK_ColonAssign && expr->kind != AST_IDENT)
|
||||
@@ -195,7 +195,7 @@ parse_init_stmt(Ast_Expr *expr){
|
||||
return expr;
|
||||
}
|
||||
|
||||
function Ast_Call *
|
||||
CORE_Static Ast_Call *
|
||||
parse_expr_call(Ast_Expr *left, Token_Kind close_kind){
|
||||
Scratch scratch;
|
||||
Token *pos = token_get();
|
||||
@@ -235,14 +235,14 @@ parse_expr_call(Ast_Expr *left, Token_Kind close_kind){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Expr *
|
||||
CORE_Static Ast_Expr *
|
||||
parse_optional_type(){
|
||||
Ast_Expr *result = 0;
|
||||
if(token_match(TK_Colon)) result = parse_expr();
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Scope *
|
||||
CORE_Static Ast_Scope *
|
||||
parse_stmt_scope(Ast_Scope *scope_defined_outside = 0){
|
||||
Ast_Scope *scope = scope_defined_outside;
|
||||
|
||||
@@ -431,7 +431,7 @@ parse_stmt_scope(Ast_Scope *scope_defined_outside = 0){
|
||||
return scope;
|
||||
}
|
||||
|
||||
function Ast_Lambda *
|
||||
CORE_Static Ast_Lambda *
|
||||
parse_lambda(Token *token){
|
||||
Scratch scratch;
|
||||
|
||||
@@ -479,7 +479,7 @@ parse_lambda(Token *token){
|
||||
struct Binding_Power{S64 left;S64 right;};
|
||||
enum Binding{Binding_Prefix,Binding_Infix,Binding_Postfix};
|
||||
|
||||
function Binding_Power
|
||||
CORE_Static Binding_Power
|
||||
binding_power(Binding binding, Token_Kind kind){
|
||||
if(binding == Binding_Prefix) goto Prefix;
|
||||
if(binding == Binding_Infix) goto Infix;
|
||||
@@ -544,7 +544,7 @@ binding_power(Binding binding, Token_Kind kind){
|
||||
}
|
||||
}
|
||||
|
||||
function Ast_Expr *
|
||||
CORE_Static Ast_Expr *
|
||||
parse_expr(S64 min_bp){
|
||||
Ast_Expr *left = 0;
|
||||
Token *token = token_next();
|
||||
@@ -651,14 +651,14 @@ parse_expr(S64 min_bp){
|
||||
return left;
|
||||
}
|
||||
|
||||
function Ast_Expr *
|
||||
CORE_Static Ast_Expr *
|
||||
parse_assign_expr(){
|
||||
Ast_Expr *result = 0;
|
||||
if(token_match(TK_Assign)) result = parse_expr();
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Decl *
|
||||
CORE_Static Ast_Decl *
|
||||
parse_struct(Token *pos){
|
||||
Scratch scratch;
|
||||
|
||||
@@ -682,7 +682,7 @@ parse_struct(Token *pos){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Decl *
|
||||
CORE_Static Ast_Decl *
|
||||
parse_enum(Token *pos){
|
||||
Scratch scratch;
|
||||
Ast_Expr *typespec = parse_optional_type();
|
||||
@@ -706,7 +706,7 @@ parse_enum(Token *pos){
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
add_implicit_import(Ast_Scope *scope, Ast_Scope *to_add){
|
||||
B32 found = false;
|
||||
Iter(&scope->implicit_imports){
|
||||
@@ -722,7 +722,7 @@ add_implicit_import(Ast_Scope *scope, Ast_Scope *to_add){
|
||||
|
||||
enum{ GLOBAL_IMPLICIT_LOAD = 1 };
|
||||
|
||||
function Ast_File *
|
||||
CORE_Static Ast_File *
|
||||
register_ast_file(Token *pos, String absolute_file_path, Ast_Module *module, B32 global_implicit_load){
|
||||
Ast_File *file = 0;
|
||||
|
||||
@@ -762,7 +762,7 @@ register_ast_file(Token *pos, String absolute_file_path, Ast_Module *module, B32
|
||||
return file;
|
||||
}
|
||||
|
||||
function Intern_String
|
||||
CORE_Static Intern_String
|
||||
preprocess_filename(Token *token_filename){
|
||||
Scratch scratch;
|
||||
String filename = token_filename->intern_val.s;
|
||||
@@ -774,7 +774,7 @@ preprocess_filename(Token *token_filename){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_File *
|
||||
CORE_Static Ast_File *
|
||||
parse_load(B32 global_implicit_load){
|
||||
Token *file = token_expect(TK_StringLit);
|
||||
Intern_String filename = preprocess_filename(file);
|
||||
@@ -783,8 +783,8 @@ parse_load(B32 global_implicit_load){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Module *add_module(Token *pos, Intern_String filename, B32 command_line_module = false);
|
||||
function Ast_Module *
|
||||
CORE_Static Ast_Module *add_module(Token *pos, Intern_String filename, B32 command_line_module = false);
|
||||
CORE_Static Ast_Module *
|
||||
parse_import(B32 global_implicit_import){
|
||||
Token *file = token_expect(TK_StringLit);
|
||||
Intern_String filename = preprocess_filename(file);
|
||||
@@ -800,7 +800,7 @@ Needs peeking only because I didn't want to duplicate code
|
||||
for parsing statements and it makes code nicer.
|
||||
Statements can have named syntax i :=
|
||||
*/
|
||||
function Ast_Decl *
|
||||
CORE_Static Ast_Decl *
|
||||
parse_decl(B32 is_global){
|
||||
Ast_Decl *result = 0;
|
||||
if(is_global) {
|
||||
@@ -906,7 +906,7 @@ parse_decl(B32 is_global){
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
parse_file(Ast_File *file){
|
||||
assert(file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user