From 0cd170bd83108b58f68b12c3d3b7f1e7e00d2fc0 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 21 Nov 2024 17:10:50 -0500 Subject: [PATCH] clean up most warnings --- src/base.rs | 30 +++++++++++++++--------------- src/main.rs | 4 ++-- src/parser.rs | 2 +- src/value.rs | 2 +- src/vm.rs | 28 ++++++++++++---------------- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1c90f91..9d89a34 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,8 +1,8 @@ // Solution to the #[derive(Clone)] problem: https://stackoverflow.com/questions/27883509/can-you-clone-a-closure use crate::value::*; use crate::vm::*; -use imbl::*; -use std::fmt; +// use imbl::*; +// use std::fmt; type LResult<'src> = Result, LudusError>; @@ -10,21 +10,21 @@ type LResult<'src> = Result, LudusError>; pub enum Base<'src> { Unary(&'src str, fn(&Value<'src>) -> LResult<'src>), Binary(&'src str, fn(&Value<'src>, &Value<'src>) -> LResult<'src>), - Ternary( - &'src str, - fn(&Value<'src>, &Value<'src>, &Value<'src>) -> LResult<'src>, - ), + // Ternary( + // &'src str, + // fn(&Value<'src>, &Value<'src>, &Value<'src>) -> LResult<'src>, + // ), } -impl<'src> Base<'src> { - pub fn name(&self) -> &'src str { - match self { - Base::Unary(name, _) => name, - Base::Binary(name, _) => name, - Base::Ternary(name, _) => name, - } - } -} +// impl<'src> Base<'src> { +// pub fn name(&self) -> &'src str { +// match self { +// Base::Unary(name, _) => name, +// Base::Binary(name, _) => name, +// Base::Ternary(name, _) => name, +// } +// } +// } pub fn eq<'src>(x: &Value<'src>, y: &Value<'src>) -> LResult<'src> { Ok(Value::Boolean(x == y)) diff --git a/src/main.rs b/src/main.rs index 23f48c9..ab2c95b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ // * [ ] perf testing use chumsky::{input::Stream, prelude::*}; -use std::rc::Rc; +// use std::rc::Rc; mod spans; @@ -44,7 +44,7 @@ mod lexer; use crate::lexer::*; mod value; -use crate::value::*; +// use crate::value::*; mod parser; use crate::parser::*; diff --git a/src/parser.rs b/src/parser.rs index 134c1b0..afdfb36 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -674,7 +674,7 @@ where .collect() .delimited_by(just(Token::Punctuation("{")), just(Token::Punctuation("}"))); - let fn_single_clause = fn_clause.clone().map_with(|c, e| vec![c]); + let fn_single_clause = fn_clause.clone().map_with(|c, _| vec![c]); let r#loop = just(Token::Reserved("loop")) .ignore_then(tuple.clone()) diff --git a/src/value.rs b/src/value.rs index 6f5c2bf..c88ce86 100644 --- a/src/value.rs +++ b/src/value.rs @@ -110,7 +110,7 @@ impl<'src> fmt::Display for Value<'src> { let name = match base { Base::Unary(name, _) => name, Base::Binary(name, _) => name, - Base::Ternary(name, _) => name, + // Base::Ternary(name, _) => name, }; write!(f, "base fn {}", name) } diff --git a/src/vm.rs b/src/vm.rs index 9995fca..8c73bae 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -275,16 +275,15 @@ pub fn apply<'src, 'a>( } else { r#fn(&args[0], &args[1]) } - } - Base::Ternary(_name, f) => { - if args.len() != 3 { - Err(LudusError { - msg: "wrong arity: expected 3 arguments".to_string(), - }) - } else { - f(&args[0], &args[1], &args[2]) - } - } + } // Base::Ternary(_name, f) => { + // if args.len() != 3 { + // Err(LudusError { + // msg: "wrong arity: expected 3 arguments".to_string(), + // }) + // } else { + // f(&args[0], &args[1], &args[2]) + // } + // } }, _ => unreachable!(), } @@ -454,17 +453,14 @@ pub fn eval<'src, 'a>( }) } Ast::Repeat(times, body) => { - let mut times_num = 0; - match eval(×.0, ctx) { - Ok(Value::Number(n)) => { - times_num = n as usize; - } + let times_num = match eval(×.0, ctx) { + Ok(Value::Number(n)) => n as usize, _ => { return Err(LudusError { msg: "repeat may only take numbers".to_string(), }) } - } + }; for _ in 0..times_num { eval(&body.0, ctx)?; }