mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
updated error names and Display
This commit is contained in:
parent
b8741ea3cc
commit
f9fe77f1e2
7 changed files with 164 additions and 81 deletions
|
|
@ -4,13 +4,13 @@ use super::CodePos;
|
|||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum LexerError {
|
||||
#[error("LexerError: Unexpected character '{c}' at {code_pos}.")]
|
||||
#[error("unexpected character '{c}' at {code_pos}.")]
|
||||
UnexpectedCharacter { c: char, code_pos: CodePos },
|
||||
#[error("LexerError: Unterminated string literal starting at {code_pos}.")]
|
||||
#[error("unterminated string literal starting at {code_pos}.")]
|
||||
UnterminatedStringLiteral { code_pos: CodePos },
|
||||
#[error("LexerError: Unterminated block comment starting at {code_pos}.")]
|
||||
#[error("unterminated block comment starting at {code_pos}.")]
|
||||
UnterminatedBlockComment { code_pos: CodePos },
|
||||
#[error("LexerError: Invalid number literal {lexeme} at {code_pos}: {msg}")]
|
||||
#[error("invalid number literal {lexeme} at {code_pos}: {msg}")]
|
||||
InvalidNumberLiteral {
|
||||
lexeme: String,
|
||||
msg: String,
|
||||
|
|
|
|||
|
|
@ -6,46 +6,46 @@ use super::Expr;
|
|||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ParserError {
|
||||
#[error("ParserError: Token stream ended unexpectedly.")]
|
||||
#[error("token stream ended unexpectedly.")]
|
||||
TokenStreamEnded,
|
||||
#[error("ParserError: Expected a primary expression, but found a {token} token instead at {0}.", token.code_pos)]
|
||||
#[error("expected a primary expression, but found a {token} token instead at {0}.", token.code_pos)]
|
||||
ExpectedPrimary { token: Token },
|
||||
#[error("ParserError: Missing semicolon at {code_pos}")]
|
||||
#[error("missing semicolon at {code_pos}")]
|
||||
MissingSemicolon { code_pos: CodePos },
|
||||
#[error("ParserError: Expected variable name at {0}, got {token} instead", token.code_pos)]
|
||||
#[error("expected variable name at {0}, got {token} instead", token.code_pos)]
|
||||
ExpectedVarName { token: Token },
|
||||
#[error("ParserError: Can't assign to {expr} at {code_pos}")]
|
||||
#[error("can't assign to {expr} at {code_pos}")]
|
||||
InvalidAssignment { expr: Expr, code_pos: CodePos },
|
||||
#[error("ParserError: Missing closing curly brace at {code_pos}")]
|
||||
#[error("missing closing curly brace at {code_pos}")]
|
||||
MissingRightBrace { code_pos: CodePos },
|
||||
#[error("ParserError: Missing closing parenthesis at {code_pos}")]
|
||||
#[error("missing closing parenthesis at {code_pos}")]
|
||||
MissingRightParen { code_pos: CodePos },
|
||||
#[error("ParserError: Missing parenthesis after if at {code_pos}")]
|
||||
#[error("missing parenthesis after if at {code_pos}")]
|
||||
MissingParenAfterIf { code_pos: CodePos },
|
||||
#[error("ParserError: Missing parenthesis after while at {code_pos}")]
|
||||
#[error("missing parenthesis after while at {code_pos}")]
|
||||
MissingParenAfterWhile { code_pos: CodePos },
|
||||
#[error("ParserError: Missing parenthesis after for at {code_pos}")]
|
||||
#[error("missing parenthesis after for at {code_pos}")]
|
||||
MissingParenAfterFor { code_pos: CodePos },
|
||||
#[error("ParserError: Call at {code_pos} has too many arguments")]
|
||||
#[error("call at {code_pos} has too many arguments")]
|
||||
TooManyArguments { code_pos: CodePos },
|
||||
#[error("ParserError: {msg} at {code_pos}")]
|
||||
#[error("{msg} at {code_pos}")]
|
||||
MissingIdentifier { msg: String, code_pos: CodePos },
|
||||
#[error("ParserError: Missing arguments to function declaration at {code_pos}")]
|
||||
#[error("missing arguments to function declaration at {code_pos}")]
|
||||
MissingFunctionArgs { code_pos: CodePos },
|
||||
#[error("ParserError: Missing body to function declaration at {code_pos}")]
|
||||
#[error("missing body to function declaration at {code_pos}")]
|
||||
MissingFunctionBody { code_pos: CodePos },
|
||||
#[error("ParserError: Function declaration at {code_pos} has too many parameters")]
|
||||
#[error("function declaration at {code_pos} has too many parameters")]
|
||||
TooManyParams { code_pos: CodePos },
|
||||
#[error("ParserError: Return statement outside of function definition")]
|
||||
#[error("return statement outside of function definition")]
|
||||
ReturnOutsideFunction { code_pos: CodePos },
|
||||
#[error("ParserError: Break statement outside of loop")]
|
||||
#[error("break statement outside of loop")]
|
||||
InvalidBreak { code_pos: CodePos },
|
||||
#[error("ParserError: Missing class body at {code_pos}")]
|
||||
#[error("missing class body at {code_pos}")]
|
||||
MissingClassBody { code_pos: CodePos },
|
||||
#[error("ParserError: Return statement in init")]
|
||||
#[error("return statement in init")]
|
||||
ReturnInInit { code_pos: CodePos },
|
||||
#[error("ParserError: Missing method name after super")]
|
||||
#[error("missing method name after super")]
|
||||
MissingMethodAfterSuper { code_pos: CodePos },
|
||||
#[error("ParserError: duplicate parameter name at {code_pos}")]
|
||||
#[error("duplicate parameter name at {code_pos}")]
|
||||
DuplicateParameterName { code_pos: CodePos },
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue