diff --git a/selfhost/parser.n b/selfhost/parser.n index a159712..b4b788c 100644 --- a/selfhost/parser.n +++ b/selfhost/parser.n @@ -168,6 +168,9 @@ fn parse_statement(context: *ParserContext) u32 { node_payload.get(result).* = type_expr; return result; } + if(.if_keyword <= p && p <= .while_keyword) { + return parse_primary_expression(context, true, -1); + } else if(p == .__keyword) { const token = context.advance(); context.expect("Expected '=' after '_'".&, .@"="); @@ -471,7 +474,7 @@ fn parse_expression_with_precedence(context: *ParserContext, require: bool, prec } fn parse_expression(context: *ParserContext) inline u32 { - return parse_expression_with_precedence(context, true, 99); + return parse_expression_with_precedence(context, true, -1); } fn parse_container_body(context: *ParserContext, is_enum: bool) u32 { diff --git a/selfhost/tokenizer.n b/selfhost/tokenizer.n index b6043f5..b6d1ba5 100644 --- a/selfhost/tokenizer.n +++ b/selfhost/tokenizer.n @@ -23,19 +23,20 @@ const TokenType = enum(u8) { //endcase_keyword, //false_keyword, fn_keyword, - if_keyword, inline_keyword, - loop_keyword, return_keyword, - //switch_keyword, //true_keyword, undefined_keyword, unreachable_keyword, var_keyword, //volatile_keyword, - while_keyword, __keyword, + if_keyword, + loop_keyword, + //switch_keyword, + while_keyword, + enum_keyword, struct_keyword, union_keyword,