Skip to content

Commit

Permalink
[dependency] Remove dependency on enum_iterator (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Dec 14, 2024
1 parent 3a01f7b commit 6c826d0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
23 changes: 0 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/samlang-ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
1 change: 0 additions & 1 deletion crates/samlang-checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 0 additions & 1 deletion crates/samlang-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
38 changes: 36 additions & 2 deletions crates/samlang-parser/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -572,7 +606,7 @@ pub(super) fn lex_source_program(
) -> Vec<Token> {
let mut stream = char_stream::CharacterStream::new(module_reference, source);
let mut tokens = vec![];
let mut known_sorted_operators = enum_iterator::all::<TokenOp>().collect::<Vec<_>>();
let mut known_sorted_operators = TOKEN_OPS.to_vec();
known_sorted_operators.sort_by_key(|op| -(op.as_str().len() as i64));

loop {
Expand Down

0 comments on commit 6c826d0

Please sign in to comment.