From 1ecee352f5844b0809d7ae66df52e34f42b44c8e Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Thu, 6 Mar 2025 20:33:27 +1300 Subject: Rewrite entire assembler The language is now more general, the code is better structured, error reporting is more detailed, and many new language features have been implemented: - conditional blocks - first-class strings - more expression operators - binary literals - negative values - invocations in constant expressions --- src/tokens/packed_binary_literal.rs | 57 ------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/tokens/packed_binary_literal.rs (limited to 'src/tokens/packed_binary_literal.rs') diff --git a/src/tokens/packed_binary_literal.rs b/src/tokens/packed_binary_literal.rs deleted file mode 100644 index a2720b7..0000000 --- a/src/tokens/packed_binary_literal.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::*; - - -pub struct PackedBinaryLiteral { - pub source: SourceSpan, - pub value: usize, - pub bits: usize, - pub fields: Vec, - pub errors: Vec, -} - -pub struct BitField { - pub name: char, - pub source: SourceSpan, - /// Length of field in bits - pub bits: usize, - /// Distance to left-shift field in value - pub shift: usize, -} - -pub struct PackedBinaryLiteralParseError { - pub source: SourceSpan, - pub variant: PackedBinaryLiteralParseErrorVariant, -} - -pub enum PackedBinaryLiteralParseErrorVariant { - DuplicateFieldName(char), - InvalidCharacter(char), -} - - -impl std::fmt::Display for PackedBinaryLiteral { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - if self.value == 0 { - write!(f, "0")?; - } else { - let bitcount = (self.value.ilog2() + 1) as usize; - 'bit: for i in (0..bitcount).rev() { - let is_first_bit = i+1 == bitcount; - if !is_first_bit && (i+1) % 4 == 0 { - write!(f, "_")?; - } - for field in &self.fields { - if i <= field.bits + field.shift - 1 && i >= field.shift { - write!(f, "{}", field.name)?; - continue 'bit; - } - } - match (self.value >> i) & 1 { - 0 => write!(f, "0")?, - _ => write!(f, "1")?, - } - } - } - return Ok(()); - } -} -- cgit v1.2.3-70-g09d2