diff --git a/compiler.h b/compiler.h index c3f6731..6b4042a 100644 --- a/compiler.h +++ b/compiler.h @@ -163,6 +163,7 @@ Intern_String keyword_true; Intern_String keyword_false; Intern_String keyword_for; Intern_String keyword_pass; +Intern_String keyword_elif; Intern_String keyword_sizeof; Intern_String keyword_alignof; Intern_String keyword_lengthof; @@ -211,6 +212,7 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){ keyword_false = l->intern("false"_s); keyword_return = l->intern("return"_s); keyword_if = l->intern("if"_s); + keyword_elif = l->intern("elif"_s); keyword_pass = l->intern("pass"_s); keyword_else = l->intern("else"_s); keyword_for = l->intern("for"_s); diff --git a/main.cpp b/main.cpp index f625420..6bd50f5 100644 --- a/main.cpp +++ b/main.cpp @@ -42,15 +42,12 @@ want to export all the symbols, we can namespace them optionally. @todo [ ] - Fix field access, cant cast, cant index -[ ] - Fix codegen renames [ ] - Add parent_scope to Ast_Type [ ] - Should compound resolution use an algorithm to reorder compounds to initialize all fields in order [ ] - Switch -[ ] - Add c string [ ] - Some way to take slice of data -[ ] - slices should be properly displayed in debugger [ ] - elif -[ ] - Imports inside of import shouldn't spill outside +[ ] - Optional function renaming [ ] - #assert that handles constants at compile time and vars at runtime [ ] - Comma notation when declaring variables thing1, thing2: S32 @@ -75,11 +72,15 @@ want to export all the symbols, we can namespace them optionally. [ ] - Conditional compilation #if @donzo +[x] - Add c string +[x] - slices should be properly displayed in debugger +[x] - Imports inside of import shouldn't spill outside [x] - Scope [x] - Hex 0x42 [x] - Rewrite where # happen, [x] - cast -> [x] - Remodel compound from call to {} +[x] - Fix codegen renames [x] - Field access rewrite [-] - Constants embeded in structs should be able to refer to other constants in that namespace without prefix [-] - Order independent constants in structs diff --git a/parsing.cpp b/parsing.cpp index 89da684..159b009 100644 --- a/parsing.cpp +++ b/parsing.cpp @@ -264,16 +264,19 @@ parse_stmt_scope(Ast_Scope *scope_defined_outside = 0){ Ast_If_Node *if_node = ast_if_node(token, init_val, expr, if_block); if_nodes.add(if_node); - while(token_is(SAME_SCOPE) && token_is_keyword(keyword_else, 1)){ + while(token_is(SAME_SCOPE) && (token_is_keyword(keyword_elif, 1) || (token_is_keyword(keyword_else, 1)))){ token_next(); - token = token_next(); - if(token_match_keyword(keyword_if)){ + token = token_get(); + if(token_match_keyword(keyword_elif)){ + assert(token->intern_val == keyword_elif); Ast_Expr *expr = parse_expr(); Ast_Scope *else_if_block = parse_stmt_scope(); Ast_If_Node *if_node = ast_if_node(token, 0, expr, else_if_block); if_nodes.add(if_node); } else{ + token_match_keyword(keyword_else); + assert(token->intern_val == keyword_else); Ast_Scope *else_block = parse_stmt_scope(); Ast_If_Node *if_node = ast_if_node(token, 0, 0, else_block); if_nodes.add(if_node);