parseid/
error.rs

1//! error types for parser
2
3use lexariel::LexerError;
4use thiserror::Error;
5
6#[derive(Error, Debug, PartialEq)]
7pub enum ParserError {
8    #[error("Unexpected token at line {line}, column {column}: expected {expected}, found {found}")]
9    UnexpectedToken {
10        line: usize,
11        column: usize,
12        expected: String,
13        found: String,
14    },
15    #[error("Unexpected end of file, expected {expected}")]
16    UnexpectedEof { expected: String },
17    #[error("Invalid addressing mode at line {line}, column {column}: {mode}")]
18    InvalidAddressingMode {
19        line: usize,
20        column: usize,
21        mode: String,
22    },
23    #[error("Missing operand for instruction {instruction} at line {line}, column {column}")]
24    MissingOperand {
25        instruction: String,
26        line: usize,
27        column: usize,
28    },
29    #[error("Invalid macro definition at line {line}, column {column}: {message}")]
30    InvalidMacroDefinition {
31        line: usize,
32        column: usize,
33        message: String,
34    },
35    #[error("Lexer error: {0}")]
36    LexerError(#[from] LexerError),
37}