register.rs: store context in error after str::parse()
This commit is contained in:
parent
938b7d2af2
commit
4314f8ee30
@ -4,7 +4,6 @@ use super::*;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// A [Register] epresents [one of the MSP430 processor's registers](https://mspgcc.sourceforge.net/manual/x82.html)
|
/// A [Register] epresents [one of the MSP430 processor's registers](https://mspgcc.sourceforge.net/manual/x82.html)
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum Register {
|
pub enum Register {
|
||||||
@ -33,7 +32,12 @@ pub enum Register {
|
|||||||
impl Parsable for Register {
|
impl Parsable for Register {
|
||||||
fn parse<'text, T>(_: &Parser, stream: &mut T) -> Result<Self, Error>
|
fn parse<'text, T>(_: &Parser, stream: &mut T) -> Result<Self, Error>
|
||||||
where T: crate::TokenStream<'text> {
|
where T: crate::TokenStream<'text> {
|
||||||
stream.expect(Type::Register).map_err(|e| e.context(stream.context()))?.lexeme().parse()
|
stream
|
||||||
|
.expect(Type::Register)
|
||||||
|
.map_err(|e: Error| e.context(stream.context()))?
|
||||||
|
.lexeme()
|
||||||
|
.parse()
|
||||||
|
.map_err(|e: Error| e.context(stream.context()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user