mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
Change lookup order for -s vs prefixes
This commit is contained in:
parent
eb185656dd
commit
755c853cc7
1 changed files with 16 additions and 16 deletions
32
src/eval.rs
32
src/eval.rs
|
@ -174,11 +174,6 @@ impl Context {
|
|||
return Some(Number(Number::one().0, unit.clone()))
|
||||
}
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
if let Some(v) = self.lookup(&name[0..name.len()-1]) {
|
||||
return Some(v)
|
||||
}
|
||||
}
|
||||
for &(ref pre, ref value) in &self.prefixes {
|
||||
if name.starts_with(pre) {
|
||||
if let Some(v) = self.lookup(&name[pre.len()..]) {
|
||||
|
@ -186,6 +181,11 @@ impl Context {
|
|||
}
|
||||
}
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
if let Some(v) = self.lookup(&name[0..name.len()-1]) {
|
||||
return Some(v)
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -207,11 +207,6 @@ impl Context {
|
|||
// we cannot canonicalize it further
|
||||
return None
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
if let Some(v) = self.canonicalize(&name[0..name.len()-1]) {
|
||||
return Some(v)
|
||||
}
|
||||
}
|
||||
for &(ref pre, ref val) in &self.prefixes {
|
||||
if name.starts_with(pre) {
|
||||
if let Some(v) = self.canonicalize(&name[pre.len()..]) {
|
||||
|
@ -225,6 +220,11 @@ impl Context {
|
|||
}
|
||||
}
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
if let Some(v) = self.canonicalize(&name[0..name.len()-1]) {
|
||||
return Some(v)
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -837,12 +837,6 @@ impl Context {
|
|||
self.visit(&unit);
|
||||
return Some(())
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
let v = Rc::new(name[0..name.len()-1].to_owned());
|
||||
if let Some(()) = self.lookup(&v) {
|
||||
return Some(())
|
||||
}
|
||||
}
|
||||
let mut found = vec![];
|
||||
for (pre, _) in &self.input {
|
||||
if let &Name::Prefix(ref pre) = pre {
|
||||
|
@ -858,6 +852,12 @@ impl Context {
|
|||
return Some(())
|
||||
}
|
||||
}
|
||||
if name.ends_with("s") {
|
||||
let v = Rc::new(name[0..name.len()-1].to_owned());
|
||||
if let Some(()) = self.lookup(&v) {
|
||||
return Some(())
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue