From 1ce90b2166747d374e140f2d7cad0a5749fbb11d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 15 Dec 2018 21:46:27 +0000 Subject: [PATCH] Remove weird bit_set shorthand; Add extra type hinting --- src/check_expr.cpp | 4 ++-- src/parser.cpp | 35 ++++++++++++----------------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1e487fb00..231b5dd3f 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2109,7 +2109,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, bool use_lhs_as case Token_NotEq: { // NOTE(bill): Allow comparisons between types check_expr_or_type(c, x, be->left); - check_expr_or_type(c, y, be->right); + check_expr_or_type(c, y, be->right, x->type); bool xt = x->mode == Addressing_Type; bool yt = y->mode == Addressing_Type; // If only one is a type, this is an error @@ -6194,7 +6194,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type case_ast_node(be, BinaryExpr, node); - check_binary_expr(c, o, node); + check_binary_expr(c, o, node, true); if (o->mode == Addressing_Invalid) { o->expr = node; return kind; diff --git a/src/parser.cpp b/src/parser.cpp index f42cfaa32..1942ea2ad 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2078,32 +2078,21 @@ Ast *parse_operand(AstFile *f, bool lhs) { case Token_bit_set: { Token token = expect_token(f, Token_bit_set); + expect_token(f, Token_OpenBracket); - if (f->curr_token.kind == Token_OpenBrace) { - Token open = expect_token(f, Token_OpenBrace); + Ast *elem = nullptr; + Ast *underlying = nullptr; - Array values = parse_element_list(f); - Token close = expect_token(f, Token_CloseBrace); - Ast *enum_type = ast_enum_type(f, token, nullptr, values); - - return ast_bit_set_type(f, token, enum_type, nullptr); - } else { - expect_token(f, Token_OpenBracket); - - Ast *elem = nullptr; - Ast *underlying = nullptr; - - bool prev_allow_range = f->allow_range; - f->allow_range = true; - elem = parse_expr(f, false); - f->allow_range = prev_allow_range; - if (allow_token(f, Token_Semicolon)) { - underlying = parse_type(f); - } - - expect_token(f, Token_CloseBracket); - return ast_bit_set_type(f, token, elem, underlying); + bool prev_allow_range = f->allow_range; + f->allow_range = true; + elem = parse_expr(f, false); + f->allow_range = prev_allow_range; + if (allow_token(f, Token_Semicolon)) { + underlying = parse_type(f); } + + expect_token(f, Token_CloseBracket); + return ast_bit_set_type(f, token, elem, underlying); } default: {