diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 2cb97ab..49c8de1 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -1,4 +1,5 @@ // © 2023 John Breaux +//! A [Comment] stores the contents of a line comment, including the preceding `;` or `//` use super::*; #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Comment(pub String); diff --git a/src/parser/identifier.rs b/src/parser/identifier.rs index bd25609..c397fa6 100644 --- a/src/parser/identifier.rs +++ b/src/parser/identifier.rs @@ -1,4 +1,5 @@ // © 2023 John Breaux +//! An [Identifier] stores the hash of a named identifier use super::*; #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Identifier { @@ -20,7 +21,7 @@ impl Parsable for Identifier { let token = stream.expect(Type::Identifier)?; match token.variant() { Type::Identifier => Ok(Self::str(token.lexeme())), - _ => unreachable!("Expected Identifier, got {token:?}"), + _ => unreachable!("Expected identifier, got {token:?}"), } } } diff --git a/src/parser/instruction.rs b/src/parser/instruction.rs index a64ab6f..57e2e9b 100644 --- a/src/parser/instruction.rs +++ b/src/parser/instruction.rs @@ -1,13 +1,13 @@ // © 2023 John Breaux //! An [Instruction] contains the [Opcode] and [Encoding] information for a single msp430 //! instruction -//! -//! -//! Note: [Opcode] and [Encoding] are very tightly coupled, because they represent interdependent parts -//! of the same instruction. This is why [Opcode]::resolve() returns an [EncodingParser] -- otherwise, -//! there's an explosion of states that I can't really cope with on my own. Really, there's about 9 -//! valid classes of instruction, some of which are only used for one or two of the MSP430's -//! instructions. +//! +//! +//! Note: [Opcode] and [Encoding] are very tightly coupled, because they represent interdependent +//! parts of the same instruction. This is why [Opcode]::resolve() returns an [EncodingParser] -- +//! otherwise, there's an explosion of states that I can't really cope with on my own. Really, +//! there's about 9 valid classes of instruction, some of which are only used for one or two of the +//! MSP430's instructions. use super::*; diff --git a/src/parser/instruction/encoding/jump_target.rs b/src/parser/instruction/encoding/jump_target.rs index 347c42b..7c6ef9c 100644 --- a/src/parser/instruction/encoding/jump_target.rs +++ b/src/parser/instruction/encoding/jump_target.rs @@ -1,9 +1,11 @@ // © 2023 John Breaux -//! A [JumpTarget] contains the [pc-relative offset](Number) or [Identifier] -//! for a [Jump instruction encoding](Encoding::Jump) +//! A [JumpTarget] contains the [pc-relative offset](Number) or [label](Identifier) +//! for a [Jump](Encoding::Jump) [instruction] use super::*; -/// The target of a [Jump](Encoding::Jump) +/// Contains the [pc-relative offset](Number) or [label](Identifier) +/// for a [Jump](Encoding::Jump) [instruction] +// TODO: Allow identifiers in JumpTarget #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct JumpTarget(Number); diff --git a/src/parser/instruction/encoding/primary_operand.rs b/src/parser/instruction/encoding/primary_operand.rs index 651f595..a2a4fad 100644 --- a/src/parser/instruction/encoding/primary_operand.rs +++ b/src/parser/instruction/encoding/primary_operand.rs @@ -1,10 +1,10 @@ // © 2023 John Breaux //! A [PrimaryOperand] contains the first [Register], addressing mode, and Extension -//! Word for an [instruction](Instruction) +//! Word for a [one-operand](Encoding::Single) or [two-operand](Encoding::Double) [instruction] use super::*; -/// The Source of a [Double](Encoding::Double) or Destination of a -/// [Single](Encoding::Single) +/// Contains the first [Register], addressing mode, and Extension Word for a +/// [one-operand](Encoding::Single) or [two-operand](Encoding::Double) [instruction] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum PrimaryOperand { Direct(Register), diff --git a/src/parser/instruction/encoding/secondary_operand.rs b/src/parser/instruction/encoding/secondary_operand.rs index 44d8f33..09a9e6b 100644 --- a/src/parser/instruction/encoding/secondary_operand.rs +++ b/src/parser/instruction/encoding/secondary_operand.rs @@ -1,6 +1,6 @@ // © 2023 John Breaux //! A [SecondaryOperand] contains the second [Register], addressing mode, and Extension -//! Word for a [two-operand](Encoding::Double) [instruction](Instruction) +//! Word for a [two-operand](Encoding::Double) [instruction] use super::*; /// The destination of a [Double](Encoding::Double) @@ -41,16 +41,16 @@ impl SecondaryOperand { } impl Parsable for SecondaryOperand { - /// Separator - /// - Register => Direct - /// - Number => Indexed - /// - OpenIdx - /// - Register - /// - CloseIdx - /// - Absolute - /// - Number - /// - Immediate - /// - Number == 0, 1 + // Separator + // - Register => Direct + // - Number => Indexed + // - OpenIdx + // - Register + // - CloseIdx + // - Absolute + // - Number + // - Immediate + // - Number == 0, 1 fn parse<'text, T>(p: &Parser, stream: &mut T) -> Result where T: crate::TokenStream<'text> { use SecondaryOperand::*; diff --git a/src/parser/instruction/encoding/width.rs b/src/parser/instruction/encoding/width.rs index 1501456..7e3c155 100644 --- a/src/parser/instruction/encoding/width.rs +++ b/src/parser/instruction/encoding/width.rs @@ -1,4 +1,5 @@ // © 2023 John Breaux +//! A [Width] represents whether an instruction operates on whole words or bytes use super::*; /// Represents an instruction's operand width.