fix: in operator

* remove `In` trait, `__in__`, `__notin__` function
* desugar to `__contains__`
* impl Collection for Array, Set, Tuple
This commit is contained in:
Shunsuke Shibayama 2023-08-13 01:01:06 +09:00
parent 4f93c393c0
commit 2e9fb48f2e
19 changed files with 154 additions and 142 deletions

View file

@ -106,6 +106,8 @@ pub enum TokenKind {
InOp,
/// `notin`
NotInOp,
// `contains`
ContainsOp,
/// `sub` (subtype of)
SubOp,
/// `is!`
@ -277,15 +279,16 @@ impl TokenKind {
BitXor => 130, // ^^
BitOr => 120, // ||
Closed | LeftOpen | RightOpen | Open => 100, // range operators
Less | Gre | LessEq | GreEq | DblEq | NotEq | InOp | NotInOp | IsOp | IsNotOp => 90, // < > <= >= == != in notin is isnot
AndOp => 80, // and
OrOp => 70, // or
FuncArrow | ProcArrow | Inclusion => 60, // -> => <-
Colon | SupertypeOf | SubtypeOf | As => 50, // : :> <: as
Comma => 40, // ,
Assign | Walrus => 20, // = :=
Newline | Semi => 10, // \n ;
LParen | LBrace | LSqBr | Indent => 0, // ( { [ Indent
Less | Gre | LessEq | GreEq | DblEq | NotEq | InOp | NotInOp | ContainsOp | IsOp
| IsNotOp => 90, // < > <= >= == != in notin contains is isnot
AndOp => 80, // and
OrOp => 70, // or
FuncArrow | ProcArrow | Inclusion => 60, // -> => <-
Colon | SupertypeOf | SubtypeOf | As => 50, // : :> <: as
Comma => 40, // ,
Assign | Walrus => 20, // = :=
Newline | Semi => 10, // \n ;
LParen | LBrace | LSqBr | Indent => 0, // ( { [ Indent
_ => return None,
};
Some(prec)