1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
This commit is contained in:
Natapat Samutpong 2022-03-23 13:03:08 +07:00
parent 8021a0e31d
commit 74adfe1f0f
3 changed files with 2 additions and 24 deletions

7
Cargo.lock generated
View file

@ -186,7 +186,6 @@ dependencies = [
name = "hir"
version = "0.1.0"
dependencies = [
"levenshtein",
"parser",
]
@ -206,12 +205,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "levenshtein"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
[[package]]
name = "lexer"
version = "0.1.0"

View file

@ -8,4 +8,3 @@ edition = "2021"
[dependencies]
parser = { path = "../parser" }
levenshtein = "1.0.5" # Used for error reporting

View file

@ -454,17 +454,3 @@ fn gen_type_hint(type_hint: &str) -> String {
_ => { dbg!(type_hint); todo!() }
}
}
// Get the closet intrinsic name to the given name
fn closet_intrinsic(got: String) -> String {
let mut closest = String::new();
let mut closest_dist = std::usize::MAX;
for intrinsic in INTRINSICS.iter() {
let dist = levenshtein::levenshtein(got.as_str(), intrinsic);
if dist < closest_dist {
closest = intrinsic.to_string();
closest_dist = dist;
}
}
closest
}