diff --git a/Cargo.lock b/Cargo.lock index 57557d4d..e6202e90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,26 +92,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "enum-iterator" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "form_urlencoded" version = "1.2.0" @@ -508,7 +488,6 @@ name = "samlang-ast" version = "0.10.1" dependencies = [ "enum-as-inner", - "enum-iterator", "itertools", "pretty_assertions", "samlang-heap", @@ -520,7 +499,6 @@ version = "0.10.1" dependencies = [ "enum-as-inner", "itertools", - "phf", "pretty_assertions", "samlang-ast", "samlang-collections", @@ -620,7 +598,6 @@ dependencies = [ name = "samlang-parser" version = "0.10.1" dependencies = [ - "enum-iterator", "itertools", "phf", "pretty_assertions", diff --git a/crates/samlang-ast/Cargo.toml b/crates/samlang-ast/Cargo.toml index 0e915486..88ff6cf7 100644 --- a/crates/samlang-ast/Cargo.toml +++ b/crates/samlang-ast/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] enum-as-inner = "0.5.1" -enum-iterator = "2.1.0" itertools = "0.13.0" samlang-heap = { path = "../samlang-heap" } diff --git a/crates/samlang-checker/Cargo.toml b/crates/samlang-checker/Cargo.toml index e16d2cfb..08ebd2b3 100644 --- a/crates/samlang-checker/Cargo.toml +++ b/crates/samlang-checker/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] enum-as-inner = "0.5.1" itertools = "0.13.0" -phf = { version = "0.11", features = ["macros"] } samlang-ast = { path = "../samlang-ast" } samlang-collections = { path = "../samlang-collections" } samlang-errors = { path = "../samlang-errors" } diff --git a/crates/samlang-parser/Cargo.toml b/crates/samlang-parser/Cargo.toml index a53adb2e..a7f3d48b 100644 --- a/crates/samlang-parser/Cargo.toml +++ b/crates/samlang-parser/Cargo.toml @@ -4,7 +4,6 @@ version = "0.10.1" edition = "2021" [dependencies] -enum-iterator = "2.1.0" itertools = "0.13.0" phf = { version = "0.11", features = ["macros"] } samlang-ast = { path = "../samlang-ast" } diff --git a/crates/samlang-parser/src/lexer.rs b/crates/samlang-parser/src/lexer.rs index 14cd4480..6b1bdde2 100644 --- a/crates/samlang-parser/src/lexer.rs +++ b/crates/samlang-parser/src/lexer.rs @@ -364,7 +364,41 @@ static KEYWORDS: phf::Map<&'static str, Keyword> = phf_map! { "assert" => Keyword::Assert, }; -#[derive(Copy, Clone, PartialEq, Eq, enum_iterator::Sequence)] +static TOKEN_OPS: [TokenOp; 31] = [ + TokenOp::Underscore, + TokenOp::LeftParenthesis, + TokenOp::RightParenthesis, + TokenOp::LeftBrace, + TokenOp::RightBrace, + TokenOp::LeftBracket, + TokenOp::RightBracket, + TokenOp::Question, + TokenOp::Semicolon, + TokenOp::Colon, + TokenOp::ColonColon, + TokenOp::Comma, + TokenOp::Dot, + TokenOp::Bar, + TokenOp::Arrow, + TokenOp::Assign, + TokenOp::Not, + TokenOp::Multiply, + TokenOp::Divide, + TokenOp::Mod, + TokenOp::Plus, + TokenOp::Minus, + TokenOp::LessThan, + TokenOp::LessThanOrEqual, + TokenOp::GreaterThan, + TokenOp::GreaterThanOrEqual, + TokenOp::Equal, + TokenOp::NotEqual, + TokenOp::And, + TokenOp::Or, + TokenOp::DotDotDot, +]; + +#[derive(Copy, Clone, PartialEq, Eq)] pub(super) enum TokenOp { Underscore, // Parentheses @@ -572,7 +606,7 @@ pub(super) fn lex_source_program( ) -> Vec { let mut stream = char_stream::CharacterStream::new(module_reference, source); let mut tokens = vec![]; - let mut known_sorted_operators = enum_iterator::all::().collect::>(); + let mut known_sorted_operators = TOKEN_OPS.to_vec(); known_sorted_operators.sort_by_key(|op| -(op.as_str().len() as i64)); loop {