diff --git a/ablescript/src/error.rs b/ablescript/src/error.rs index 855b213..d78aa25 100644 --- a/ablescript/src/error.rs +++ b/ablescript/src/error.rs @@ -14,10 +14,10 @@ pub enum ErrorKind { UnknownVariable(String), MeloVariable(String), TopLevelBreak, - BfInterpretError(InterpretError), - MismatchedArgumentError, + MismatchedArity, MissingLhs, - IoError(io::Error), + Brian(InterpretError), + Io(io::Error), } impl Error { @@ -52,17 +52,17 @@ impl Display for ErrorKind { ErrorKind::UnknownVariable(name) => write!(f, "unknown identifier \"{}\"", name), ErrorKind::MeloVariable(name) => write!(f, "banned variable \"{}\"", name), ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"), - ErrorKind::BfInterpretError(err) => write!(f, "brainfuck error: {}", err), + ErrorKind::Brian(err) => write!(f, "brainfuck error: {}", err), // TODO: give concrete numbers here. - ErrorKind::MismatchedArgumentError => write!(f, "wrong number of function arguments"), + ErrorKind::MismatchedArity => write!(f, "wrong number of function arguments"), ErrorKind::MissingLhs => write!(f, "missing expression before binary operation"), - ErrorKind::IoError(err) => write!(f, "I/O error: {}", err), + ErrorKind::Io(err) => write!(f, "I/O error: {}", err), } } } impl From for ErrorKind { fn from(e: io::Error) -> Self { - Self::IoError(e) + Self::Io(e) } } diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index 83075af..7cdd7a4 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -428,7 +428,7 @@ impl ExecEnv { ) .interpret_with_output(&mut output) .map_err(|e| Error { - kind: ErrorKind::BfInterpretError(e), + kind: ErrorKind::Brian(e), span: span.to_owned(), })?; @@ -439,7 +439,7 @@ impl ExecEnv { Functio::Able { params, body } => { if params.len() != args.len() { return Err(Error { - kind: ErrorKind::MismatchedArgumentError, + kind: ErrorKind::MismatchedArity, span: span.to_owned(), }); } @@ -477,7 +477,7 @@ impl ExecEnv { Functio::Eval(code) => { if !args.is_empty() { return Err(Error { - kind: ErrorKind::MismatchedArgumentError, + kind: ErrorKind::MismatchedArity, span: span.to_owned(), }); }