diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-04 23:50:46 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-04 23:50:46 +0300 |
commit | fdae943090463526423f5e43e72cd2f0e8147a1b (patch) | |
tree | 5a7212555d8511df16fe6bbcc54b863ec9463b46 /src/sexp | |
parent | 36d2818d39e61b752923e253f8455f50510cb428 (diff) | |
download | myslip-fdae943090463526423f5e43e72cd2f0e8147a1b.tar.gz myslip-fdae943090463526423f5e43e72cd2f0e8147a1b.zip |
Added repl and some documentation. Improved error messages. Removed dead code.
* Removed same_variant in parse::parsetree
* Added SExp::multistep (for use of the repl)
Improved error messages:
* Added parenthesis around types
* Changed how errors propagate inferring generics:
added the error variant ArgumentsDontMatchGeneric,
implemented the displaying of it, added tests for
it.
* Had to change some tests to match for the new changes
Diffstat (limited to 'src/sexp')
-rw-r--r-- | src/sexp/display.rs | 25 | ||||
-rw-r--r-- | src/sexp/step.rs | 8 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/sexp/display.rs b/src/sexp/display.rs index e6dbb7c..238e8d4 100644 --- a/src/sexp/display.rs +++ b/src/sexp/display.rs @@ -26,20 +26,17 @@ impl fmt::Display for SExp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Atom(leaf) => write!(f, "{}", leaf.to_string()), - SCons(a, b) => { - match scons(a.clone(), b.clone()).into_vec() { - Ok(l) => write!( - f, - "({})", - l.into_iter() - .map(|x| x.to_string()) - .collect::<Vec<String>>() - .join(" ") - ), - Err(_) => write!(f, "({} {})", *a, *b), - } - } + SCons(a, b) => + write!( + f, + "({})", + scons(a.clone(), b.clone()) + .parts() + .into_iter() + .map(|x| x.to_string()) + .collect::<Vec<String>>() + .join(" ") + ) } } - } diff --git a/src/sexp/step.rs b/src/sexp/step.rs index 765e33c..1ab0291 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -209,4 +209,12 @@ impl SExp { t => Err(format!("unimplemented: {:?}.step()", t)), } } + + + pub fn multistep(self) -> Result<Self, String> { + match self.clone().step()? { + x if x == self => Ok(self), + x => x.multistep() + } + } } |