mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Allow not_in as keyword over notin, but still allow notin to work
This commit is contained in:
+3
-3
@@ -2397,7 +2397,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint
|
||||
}
|
||||
|
||||
case Token_in:
|
||||
case Token_notin:
|
||||
case Token_not_in:
|
||||
// IMPORTANT NOTE(bill): This uses right-left evaluation in type checking only no in
|
||||
|
||||
check_expr(c, y, be->right);
|
||||
@@ -2426,7 +2426,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint
|
||||
if (op.kind == Token_in) {
|
||||
check_assignment(c, x, yt->Map.key, str_lit("map 'in'"));
|
||||
} else {
|
||||
check_assignment(c, x, yt->Map.key, str_lit("map 'notin'"));
|
||||
check_assignment(c, x, yt->Map.key, str_lit("map 'not_in'"));
|
||||
}
|
||||
|
||||
add_package_dependency(c, "runtime", "__dynamic_map_get");
|
||||
@@ -2436,7 +2436,7 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint
|
||||
if (op.kind == Token_in) {
|
||||
check_assignment(c, x, yt->BitSet.elem, str_lit("bit_set 'in'"));
|
||||
} else {
|
||||
check_assignment(c, x, yt->BitSet.elem, str_lit("bit_set 'notin'"));
|
||||
check_assignment(c, x, yt->BitSet.elem, str_lit("bit_set 'not_in'"));
|
||||
}
|
||||
if (x->mode == Addressing_Constant && y->mode == Addressing_Constant) {
|
||||
ExactValue k = exact_value_to_integer(x->value);
|
||||
|
||||
+3
-3
@@ -7302,7 +7302,7 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
|
||||
|
||||
|
||||
case Token_in:
|
||||
case Token_notin: {
|
||||
case Token_not_in: {
|
||||
irValue *left = ir_build_expr(proc, be->left);
|
||||
Type *type = default_type(tv.type);
|
||||
irValue *right = ir_build_expr(proc, be->right);
|
||||
@@ -7313,7 +7313,7 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
|
||||
if (be->op.kind == Token_in) {
|
||||
ir_emit_comment(proc, str_lit("map in"));
|
||||
} else {
|
||||
ir_emit_comment(proc, str_lit("map notin"));
|
||||
ir_emit_comment(proc, str_lit("map not_in"));
|
||||
}
|
||||
|
||||
irValue *addr = ir_address_from_load_or_generate_local(proc, right);
|
||||
@@ -7337,7 +7337,7 @@ irValue *ir_build_expr_internal(irProcedure *proc, Ast *expr) {
|
||||
if (be->op.kind == Token_in) {
|
||||
ir_emit_comment(proc, str_lit("bit_set in"));
|
||||
} else {
|
||||
ir_emit_comment(proc, str_lit("bit_set notin"));
|
||||
ir_emit_comment(proc, str_lit("bit_set not_in"));
|
||||
}
|
||||
|
||||
Type *key_type = rt->BitSet.elem;
|
||||
|
||||
+2
-2
@@ -1196,7 +1196,7 @@ bool is_token_range(Token tok) {
|
||||
|
||||
Token expect_operator(AstFile *f) {
|
||||
Token prev = f->curr_token;
|
||||
if ((prev.kind == Token_in || prev.kind == Token_notin) && (f->expr_level >= 0 || f->allow_in_expr)) {
|
||||
if ((prev.kind == Token_in || prev.kind == Token_not_in) && (f->expr_level >= 0 || f->allow_in_expr)) {
|
||||
// okay
|
||||
} else if (!gb_is_between(prev.kind, Token__OperatorBegin+1, Token__OperatorEnd-1)) {
|
||||
syntax_error(f->curr_token, "Expected an operator, got '%.*s'",
|
||||
@@ -2515,7 +2515,7 @@ i32 token_precedence(AstFile *f, TokenKind t) {
|
||||
return 5;
|
||||
|
||||
case Token_in:
|
||||
case Token_notin:
|
||||
case Token_not_in:
|
||||
if (f->expr_level < 0 && !f->allow_in_expr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+10
-6
@@ -92,7 +92,7 @@ TOKEN_KIND(Token__KeywordBegin, ""), \
|
||||
TOKEN_KIND(Token_for, "for"), \
|
||||
TOKEN_KIND(Token_switch, "switch"), \
|
||||
TOKEN_KIND(Token_in, "in"), \
|
||||
TOKEN_KIND(Token_notin, "notin"), \
|
||||
TOKEN_KIND(Token_not_in, "not_in"), \
|
||||
TOKEN_KIND(Token_do, "do"), \
|
||||
TOKEN_KIND(Token_case, "case"), \
|
||||
TOKEN_KIND(Token_break, "break"), \
|
||||
@@ -902,6 +902,10 @@ Token tokenizer_get_token(Tokenizer *t) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (token.kind == Token_Ident && token.string == "notin") {
|
||||
token.kind = Token_not_in;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (gb_is_between(curr_rune, '0', '9')) {
|
||||
@@ -1029,11 +1033,11 @@ Token tokenizer_get_token(Tokenizer *t) {
|
||||
case '}': token.kind = Token_CloseBrace; break;
|
||||
case '\\': token.kind = Token_BackSlash; break;
|
||||
|
||||
case 0x2260: token.kind = Token_NotEq; break; // '≠'
|
||||
case 0x2264: token.kind = Token_LtEq; break; // '≤'
|
||||
case 0x2265: token.kind = Token_GtEq; break; // '≥'
|
||||
case 0x2208: token.kind = Token_in; break; // '∈'
|
||||
case 0x2209: token.kind = Token_notin; break; // '∉'
|
||||
// case 0x2260: token.kind = Token_NotEq; break; // '≠'
|
||||
// case 0x2264: token.kind = Token_LtEq; break; // '≤'
|
||||
// case 0x2265: token.kind = Token_GtEq; break; // '≥'
|
||||
// case 0x2208: token.kind = Token_in; break; // '∈'
|
||||
// case 0x2209: token.kind = Token_not_in; break; // '∉'
|
||||
|
||||
case '%': token.kind = token_kind_dub_eq(t, '%', Token_Mod, Token_ModEq, Token_ModMod, Token_ModModEq); break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user