[−][src]Enum pir_8_emu::isa::instruction::ParseInstructionError
pub enum ParseInstructionError { InvalidCharacter(usize), EmptyString, UnrecognisedToken(usize, &'static [&'static str]), UnrecognisedRegisterLetter(usize, char, [char; 8]), MissingToken(usize, &'static [&'static str]), MissingRegisterLetter(usize, [char; 8]), TooManyTokens(usize), }
An error that could've occurred when parsing an Instruction
or an
AluOperation
.
Examples
let res = Instruction::from_str("LOAD IND Q", ®isters); assert_eq!(res, Err(ParseInstructionError::UnrecognisedRegisterLetter( 10, 'Q', ['F', 'S', 'X', 'Y', 'A', 'B', 'C', 'D']))); assert_eq!(format!("\nLOAD IND Q\n{}\n", res.unwrap_err()), "\nLOAD IND Q\n ^ Register Q not found; expected: F, S, X, Y, A, B, C, D\n"); /* " LOAD IND Q ^ Register Q not found; expected: F, S, X, Y, A, B, C, D "); */ let res = Instruction::from_str(" PORT", ®isters); assert_eq!(res, Err(ParseInstructionError::MissingToken(8, &["IN", "OUT"]))); assert_eq!(format!("\n PORT\n{}\n", res.unwrap_err()), "\n PORT\nIN, OUT ^ <- expected: Missing token\n"); /* " PORT IN, OUT ^ <- expected: Missing token "); */
Variants
InvalidCharacter(usize)
An invalid (non-ASCII/vertical-WS) character was found in the input string
The string to be parsed contained no tokens
UnrecognisedToken(usize, &'static [&'static str])
A token was specified that doesn't fit in the place it was used
The specified register letter was specified but no register with that letter exists
MissingToken(usize, &'static [&'static str])
A token was not specified, but one was required in that place
A register name was not specified, but one was required in that place
TooManyTokens(usize)
A token was specified after a successful parse
Trait Implementations
impl Clone for ParseInstructionError
[src][+]
impl Copy for ParseInstructionError
[src]
impl Debug for ParseInstructionError
[src][+]
impl Display for ParseInstructionError
[src][+]
impl Eq for ParseInstructionError
[src]
impl Error for ParseInstructionError
[src][+]
impl Hash for ParseInstructionError
[src][+]
impl Ord for ParseInstructionError
[src][+]
impl PartialEq<ParseInstructionError> for ParseInstructionError
[src][+]
impl PartialOrd<ParseInstructionError> for ParseInstructionError
[src][+]
impl StructuralEq for ParseInstructionError
[src]
impl StructuralPartialEq for ParseInstructionError
[src]
Auto Trait Implementations
impl RefUnwindSafe for ParseInstructionError
impl Send for ParseInstructionError
impl Sync for ParseInstructionError
impl Unpin for ParseInstructionError
impl UnwindSafe for ParseInstructionError
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> Downcast for T where
T: Any,
[src][+]
T: Any,
impl<T> DowncastSync for T where
T: Send + Sync + Any,
[src][+]
T: Send + Sync + Any,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,