improved REPL a bit

now uses rustyline for input
This commit is contained in:
Moritz Gmeiner 2024-09-02 03:10:35 +02:00
commit fb88595b6c
13 changed files with 560 additions and 100 deletions

View file

@ -17,7 +17,11 @@ pub enum RuntimeError {
#[error("Opcopde {opcode} had invalid operand {operand}")]
UnaryInvalidOperand { opcode: Opcode, operand: Value },
#[error("Opcopde {opcode} had invalid operands {left} and {right}")]
BinaryInvalidOperand { opcode: Opcode, left: Value, right: Value },
BinaryInvalidOperand {
opcode: Opcode,
left: Value,
right: Value,
},
#[error("Division by zero")]
DivisionByZero,
}
@ -52,7 +56,7 @@ impl From<RuntimeError> for LoxError {
}
}
fn format_multiple_errors(errs: &Vec<impl std::error::Error>) -> String {
fn format_multiple_errors(errs: &[impl std::error::Error]) -> String {
let msg = if errs.len() == 1 {
errs[0].to_string()
} else {