From b70ef2743efe93ec7b8e2c3e83b30227db10baf1 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Fri, 17 Jan 2020 14:43:43 -0500 Subject: [PATCH] Make parser conform to v0.2.1 --- toolchain/src/inst.rs | 2 +- toolchain/src/inst/decode.rs | 2 +- toolchain/src/inst/encode.rs | 2 +- toolchain/src/inst/format.rs | 2 +- toolchain/src/inst/parse.rs | 2 +- toolchain/src/inst/test.rs | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/toolchain/src/inst.rs b/toolchain/src/inst.rs index e04b339..89673ba 100644 --- a/toolchain/src/inst.rs +++ b/toolchain/src/inst.rs @@ -99,7 +99,7 @@ pub enum LdSt { #[cfg_attr(test, derive(Arbitrary))] #[cfg_attr(test, proptest(no_params))] pub enum Inst { - Trap, + Stop, Nope, Prnt, CAbA, diff --git a/toolchain/src/inst/decode.rs b/toolchain/src/inst/decode.rs index a83d8fc..d5cf3ae 100644 --- a/toolchain/src/inst/decode.rs +++ b/toolchain/src/inst/decode.rs @@ -92,7 +92,7 @@ impl Decode for Inst { let mut op_byte = [0]; reader.read_exact(&mut op_byte)?; Ok(match (op_byte[0] >> 3, op_byte[0] & 7) { - (0b0000_0, 0b000) => Inst::Trap, + (0b0000_0, 0b000) => Inst::Stop, (0b0000_0, 0b001) => Inst::Nope, (0b0000_0, 0b010) => Inst::Prnt, (0b0000_0, 0b110) => Inst::CAbA, diff --git a/toolchain/src/inst/encode.rs b/toolchain/src/inst/encode.rs index 6515aa6..b08f68f 100644 --- a/toolchain/src/inst/encode.rs +++ b/toolchain/src/inst/encode.rs @@ -20,7 +20,7 @@ fn sp(s: Special) -> u8 { impl Encode for Inst { fn encode(&self, writer: &mut impl Write) -> io::Result<()> { match *self { - Inst::Trap => writer.write(&[0x00])?, + Inst::Stop => writer.write(&[0x00])?, Inst::Nope => writer.write(&[0x01])?, Inst::Prnt => writer.write(&[0x02])?, Inst::CAbA => writer.write(&[0x06])?, diff --git a/toolchain/src/inst/format.rs b/toolchain/src/inst/format.rs index c840e04..83a490e 100644 --- a/toolchain/src/inst/format.rs +++ b/toolchain/src/inst/format.rs @@ -27,7 +27,7 @@ impl Display for Inst { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { use Inst::*; match *self { - Trap => write!(fmt, "TRAP"), + Stop => write!(fmt, "STOP"), Nope => write!(fmt, "NOPE"), Prnt => write!(fmt, "PRNT"), CAbA => write!(fmt, "CABA"), diff --git a/toolchain/src/inst/parse.rs b/toolchain/src/inst/parse.rs index 87d1669..5eeff9a 100644 --- a/toolchain/src/inst/parse.rs +++ b/toolchain/src/inst/parse.rs @@ -17,7 +17,7 @@ pub fn parse_inst(s: &str) -> Option { pub fn inst(s: &str) -> IResult<&str, Inst> { alt(( alt(( - fixed("TRAP", Inst::Trap), + fixed("STOP", Inst::Stop), fixed("NOPE", Inst::Nope), fixed("PRNT", Inst::Prnt), fixed("CABA", Inst::CAbA), diff --git a/toolchain/src/inst/test.rs b/toolchain/src/inst/test.rs index 3422b5e..0f04485 100644 --- a/toolchain/src/inst/test.rs +++ b/toolchain/src/inst/test.rs @@ -63,10 +63,10 @@ macro_rules! test_parse { } #[test] -fn trap() { +fn stop() { test_parse! { - "TRAP" => "0000_0000", - "trap" => "0000_0000", + "STOP" => "0000_0000", + "stop" => "0000_0000", } } -- 2.47.0