mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Allow not_in as keyword over notin, but still allow notin to work
This commit is contained in:
@@ -1146,7 +1146,7 @@ token_precedence :: proc(p: ^Parser, kind: tokenizer.Token_Kind) -> int {
|
||||
.Lt, .Gt,
|
||||
.Lt_Eq, .Gt_Eq:
|
||||
return 5;
|
||||
case .In, .Notin:
|
||||
case .In, .Not_In:
|
||||
if p.expr_level < 0 && !p.allow_in_expr {
|
||||
return 0;
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ check_field_flag_prefixes :: proc(p: ^Parser, name_count: int, allowed_flags, se
|
||||
}
|
||||
|
||||
for flag in ast.Field_Flag {
|
||||
if flag notin allowed_flags && flag in flags {
|
||||
if flag not_in allowed_flags && flag in flags {
|
||||
switch flag {
|
||||
case .Using:
|
||||
error(p, p.curr_tok.pos, "'using' is not allowed within this field list");
|
||||
@@ -1557,7 +1557,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
|
||||
if allow_token(p, .Eq) {
|
||||
default_value = parse_expr(p, false);
|
||||
if ast.Field_Flag.Default_Parameters notin allowed_flags {
|
||||
if ast.Field_Flag.Default_Parameters not_in allowed_flags {
|
||||
error(p, p.curr_tok.pos, "default parameters are only allowed for procedures");
|
||||
default_value = nil;
|
||||
}
|
||||
@@ -1585,7 +1585,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
if type != nil && default_value == nil {
|
||||
if p.curr_tok.kind == .String {
|
||||
tag = expect_token(p, .String);
|
||||
if .Tags notin allowed_flags {
|
||||
if .Tags not_in allowed_flags {
|
||||
error(p, tag.pos, "Field tags are only allowed within structures");
|
||||
}
|
||||
}
|
||||
@@ -1644,7 +1644,7 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
|
||||
type := eaf.expr;
|
||||
tok: tokenizer.Token;
|
||||
tok.pos = type.pos;
|
||||
if ast.Field_Flag.Results notin allowed_flags {
|
||||
if ast.Field_Flag.Results not_in allowed_flags {
|
||||
tok.text = "_";
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ Token_Kind :: enum u32 {
|
||||
For,
|
||||
Switch,
|
||||
In,
|
||||
Notin,
|
||||
Not_In,
|
||||
Do,
|
||||
Case,
|
||||
Break,
|
||||
@@ -259,7 +259,7 @@ tokens := [Token_Kind.COUNT]string {
|
||||
"for",
|
||||
"switch",
|
||||
"in",
|
||||
"notin",
|
||||
"not_in",
|
||||
"do",
|
||||
"case",
|
||||
"break",
|
||||
@@ -316,7 +316,7 @@ is_operator :: proc(kind: Token_Kind) -> bool {
|
||||
#partial switch kind {
|
||||
case .B_Operator_Begin .. .B_Operator_End:
|
||||
return true;
|
||||
case .In, .Notin:
|
||||
case .In, .Not_In:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -501,6 +501,9 @@ scan :: proc(t: ^Tokenizer) -> Token {
|
||||
break check_keyword;
|
||||
}
|
||||
}
|
||||
if kind == .Ident && lit == "notin" {
|
||||
kind = .Not_In;
|
||||
}
|
||||
}
|
||||
case '0' <= ch && ch <= '9':
|
||||
kind, lit = scan_number(t, false);
|
||||
@@ -575,12 +578,6 @@ scan :: proc(t: ^Tokenizer) -> Token {
|
||||
}
|
||||
case '>': kind = switch4(t, .Gt, .Gt_Eq, '>', .Shr,.Shr_Eq);
|
||||
|
||||
case '≠': kind = .Not_Eq;
|
||||
case '≤': kind = .Lt_Eq;
|
||||
case '≥': kind = .Gt_Eq;
|
||||
case '∈': kind = .In;
|
||||
case '∉': kind = .Notin;
|
||||
|
||||
case '.':
|
||||
if '0' <= t.ch && t.ch <= '9' {
|
||||
kind, lit = scan_number(t, true);
|
||||
|
||||
Reference in New Issue
Block a user