use std::num::TryFromIntError;
use thiserror::Error as ThisError;
use corewars_core::load_file::Opcode;
#[derive(ThisError, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
#[error("no such label {label:?}")]
LabelNotFound { label: String, line: Option<usize> },
#[error("invalid origin specified")]
InvalidOrigin(#[from] TryFromIntError),
#[error("invalid syntax")]
InvalidSyntax(#[from] Box<super::grammar::SyntaxError>),
#[error("expected additional arguments for {opcode} opcode")]
InvalidArguments { opcode: Opcode },
}
#[derive(ThisError, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Warning {
#[error("origin already defined as {old:?}, new definition {new:?} will be ignored")]
OriginRedefinition { old: String, new: String },
#[error("right-hand side of substitution for label {0:?} is empty")]
EmptySubstitution(String),
#[error("no instruction offset for label {0:?}, it will not b")]
EmptyOffset(String),
}