[][src]Enum pir_8_emu::isa::instruction::ParseInstructionError

pub enum ParseInstructionError {
    InvalidCharacter(usize),
    EmptyString,
    UnrecognisedToken(usize&'static [&'static str]),
    UnrecognisedRegisterLetter(usizechar[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", &registers);
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", &registers);
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

EmptyString

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

UnrecognisedRegisterLetter(usizechar[char; 8])

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

MissingRegisterLetter(usize[char; 8])

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.