refactor(tazjin/rlox): Add Interpreter trait for switching impls

Change-Id: Iae28d64ce879014c5e5d7e145c536c1f16ad307d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2418
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2021-01-18 03:21:52 +03:00 committed by tazjin
parent d6d3c12efb
commit 1ff7a2686c
8 changed files with 125 additions and 102 deletions

View file

@ -1,4 +1,5 @@
use crate::treewalk::interpreter::Value;
use std::fmt;
#[derive(Debug)]
pub enum ErrorKind {
@ -33,6 +34,8 @@ pub struct Error {
pub kind: ErrorKind,
}
pub fn report(err: &Error) {
eprintln!("[line {}] Error: {:?}", err.line, err.kind);
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "[line {}] Error: {:?}", self.line, self.kind)
}
}