Fix scope bug, fix parsing bug
This commit is contained in:
@@ -221,7 +221,6 @@ gen_ast(Ast *ast){
|
||||
|
||||
CASE(PACKAGE, Package){
|
||||
For(node->ordered) {
|
||||
genln("");
|
||||
genln("");
|
||||
gen_ast(it);
|
||||
}
|
||||
|
||||
2
main.cpp
2
main.cpp
@@ -176,7 +176,7 @@ int main(){
|
||||
|
||||
|
||||
String result = {};
|
||||
#if 0
|
||||
#if 1
|
||||
result = compile_file("globals.kl"_s);
|
||||
printf("%s", result.str);
|
||||
result = compile_file("enums.kl"_s);
|
||||
|
||||
@@ -333,11 +333,12 @@ binding_power(Binding binding, Token_Kind kind){
|
||||
else invalid_codepath;
|
||||
|
||||
Prefix: switch(kind){
|
||||
case TK_OpenBracket:
|
||||
return {-2, 22};
|
||||
case TK_Increment:
|
||||
case TK_Decrement:
|
||||
case TK_Pointer:
|
||||
case TK_Dereference:
|
||||
case TK_OpenBracket:
|
||||
case TK_Keyword:
|
||||
case TK_OpenParen:
|
||||
case TK_Sub:
|
||||
|
||||
@@ -56,7 +56,7 @@ test_assignments :: ()
|
||||
i >>= 2
|
||||
i <<= 2
|
||||
|
||||
i = i > 2
|
||||
boolean := i > 2
|
||||
CONST :: 23 == 23
|
||||
CONST_FLOAT :: 23.52
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ int main(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct Token{
|
||||
U8 kind;
|
||||
U8 *str;
|
||||
@@ -41,7 +39,6 @@ typedef struct Token{
|
||||
Number = 0,
|
||||
};*/
|
||||
}Token;
|
||||
|
||||
String kind_name(U8 kind){
|
||||
if((kind==0)){
|
||||
return LIT("<Number>");
|
||||
@@ -50,12 +47,10 @@ String kind_name(U8 kind){
|
||||
return LIT("<Unknown>");
|
||||
}
|
||||
}
|
||||
|
||||
Bool is_numeric(U8 c){
|
||||
Bool result = ((c>=48)&&(c<=57));
|
||||
return result;
|
||||
}
|
||||
|
||||
void entry(){
|
||||
String string_to_lex = LIT("Identifier 2425525 Not_Number");
|
||||
Token token_array[32];
|
||||
|
||||
@@ -349,12 +349,6 @@ resolve_typespec(Ast_Expr *ast, B32 ast_can_be_null){
|
||||
return resolved.type_val;
|
||||
}
|
||||
|
||||
function void resolve_stmt(Ast *ast, Ast_Resolved_Type *ret);
|
||||
function void
|
||||
resolve_stmt_block(Ast_Block *block, Ast_Resolved_Type *ret){
|
||||
|
||||
}
|
||||
|
||||
// @note: Ret is return value of function passed down the stack
|
||||
// to check if type matches
|
||||
function void
|
||||
@@ -395,25 +389,24 @@ resolve_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
}
|
||||
}
|
||||
|
||||
Scope(){
|
||||
S64 scope = scope_open();
|
||||
resolve_expr(node->init, ret);
|
||||
resolve_expr(node->cond, ret);
|
||||
resolve_expr(node->iter, ret);
|
||||
For(node->block->stmts)
|
||||
resolve_stmt(it, ret);
|
||||
}
|
||||
scope_close(scope);
|
||||
BREAK();
|
||||
}
|
||||
|
||||
CASE(IF, If){
|
||||
For(node->ifs){
|
||||
resolve_stmt(it->init, ret);
|
||||
Scope(){
|
||||
S64 scope = scope_open();
|
||||
resolve_expr(it->expr); // @todo: typechecking
|
||||
resolve_stmt_block(it->block, ret);
|
||||
For_It(it->block->stmts, jt)
|
||||
resolve_stmt(jt, ret);
|
||||
}
|
||||
scope_close(scope);
|
||||
}
|
||||
BREAK();
|
||||
}
|
||||
|
||||
@@ -72,8 +72,6 @@ scope_close(S64 local_sym_count){
|
||||
pctx->local_syms.len = local_sym_count;
|
||||
}
|
||||
|
||||
#define Scope() for(S64 scope_index = scope_open(); scope_index; (scope_close(scope_index), scope_index=0))
|
||||
|
||||
function void
|
||||
sym_associate(Ast *ast, Sym *sym){
|
||||
assert(ast);
|
||||
|
||||
Reference in New Issue
Block a user