diff --git a/rust/rox/src/interpreter.rs b/rust/rox/src/interpreter.rs index 30fd264..819092c 100644 --- a/rust/rox/src/interpreter.rs +++ b/rust/rox/src/interpreter.rs @@ -17,21 +17,21 @@ use crate::{ #[derive(Error, Debug)] pub enum InterpreterError { - #[error("[line {0}] MINUS unary expression expects a number on the right")] + #[error("line {0}: MINUS unary expression expects a number on the right")] UnaryExpressionNotANumber(usize), - #[error("[line {0}] unknown unary operator: {1}")] + #[error("line {0}: unknown unary operator: {1}")] UnaryOperatorUnknown(usize, String), - #[error("[line {0}] unknown binary operator: {1}")] + #[error("line {0}: unknown binary operator: {1}")] BinaryOperatorUnknown(usize, String), - #[error("[line {0}] left or right is not a number.")] + #[error("line {0}: left or right is not a number.")] BinaryExpressionNeedsNumber(usize), - #[error("[line {0}] left or right is neither a number nor string.")] + #[error("line {0}: left or right is neither a number nor string.")] BinaryExpressionNeedsNumberOrString(usize), #[error("{0}")] UndefinedVariable(EnvironmentError), - #[error("[line {0}] {1} is not callable.")] + #[error("line {0}: {1} is not callable.")] NotACallable(usize, Value), - #[error("[line {0}] {1}.")] + #[error("line {0}: {1}.")] FailedToCall(usize, CallingError), } diff --git a/rust/rox/src/parser.rs b/rust/rox/src/parser.rs index 1d0892c..6952a5c 100644 --- a/rust/rox/src/parser.rs +++ b/rust/rox/src/parser.rs @@ -13,49 +13,49 @@ use tracing::error; pub enum ParserError { #[error("empty token stream")] NoTokens, - #[error("[line {0}] expected expression")] + #[error("line {0}: expected expression")] ExpressionExpected(usize), - #[error("[line {0}] expected ')' after expression.")] + #[error("line {0}: expected ')' after expression.")] ParenAfterExpression(usize), - #[error("[Out of bounds access at index {0}.")] + #[error("Out of bounds access at index {0}.")] OutOfBoundsAccess(usize), - #[error("[line {0}] literal expected.")] + #[error("line {0}: literal expected.")] LiteralExpected(usize), - #[error("[line {0}] expected ';' after value.")] + #[error("line {0}: expected ';' after value.")] SemicolonAfterValueExpected(usize), - #[error("[line {0}] expected ';' after expression.")] + #[error("line {0}: expected ';' after expression.")] SemicolonAfterExpressionExpected(usize), - #[error("[line {0}] expected variable name.")] + #[error("line {0}: expected variable name.")] VariableNameExpected(usize), - #[error("[line {0}] invalid assignment target.")] + #[error("line {0}: invalid assignment target.")] InvalidAssignmentTarget(usize), - #[error("[line {0}] expected '}}' after block.")] + #[error("line {0}: expected '}}' after block.")] RightBraceAfterBlockExpected(usize), - #[error("[line {0}] expected '(' after if.")] + #[error("line {0}: expected '(' after if.")] LeftParenAfterIfExpected(usize), - #[error("[line {0}] expected ')' after condition.")] + #[error("line {0}: expected ')' after condition.")] RightParenAfterConditionExpected(usize), - #[error("[line {0}] expected '(' after while.")] + #[error("line {0}: expected '(' after while.")] LeftParenAfterWhileExpected(usize), - #[error("[line {0}] expected '(' after for.")] + #[error("line {0}: expected '(' after for.")] LeftParenAfterForExpected(usize), - #[error("[line {0}] expected ';' after loop condition.")] + #[error("line {0}: expected ';' after loop condition.")] SemicolonAfterLoopConditionExpected(usize), - #[error("[line {0}] expected ')' after for clauses.")] + #[error("line {0}: expected ')' after for clauses.")] RightParenAfterForClausesExpected(usize), - #[error("[line {0}] expected ')' after arguments.")] + #[error("line {0}: expected ')' after arguments.")] RightParenAfterArgumentsExpected(usize), - #[error("[line {0}] expected function name.")] + #[error("line {0}: expected function name.")] FunctionNameExpected(usize), - #[error("[line {0}] expected '(' after function name.")] + #[error("line {0}: expected '(' after function name.")] LeftParenAfterFunctionNameExpected(usize), - #[error("[line {0}] expected ')' after parameters.")] + #[error("line {0}: expected ')' after parameters.")] RightParenAfterParamsExpected(usize), - #[error("[line {0}] expected parameter name.")] + #[error("line {0}: expected parameter name.")] ParamNameExpected(usize), - #[error("[line {0}] expected '{{' before function body.")] + #[error("line {0}: expected '{{' before function body.")] LeftBraceBeforeFunctionBodyExpected(usize), - #[error("[line {0}] expected ';' after return value.")] + #[error("line {0}: expected ';' after return value.")] SemicolonAfterReturnExpected(usize), }