diff options
| author | Ben Bridle <ben@derelict.engineering> | 2025-02-27 14:53:21 +1300 | 
|---|---|---|
| committer | Ben Bridle <ben@derelict.engineering> | 2025-02-27 14:53:31 +1300 | 
| commit | 67470aea034fd46f4bbcfe815c51ad3451043188 (patch) | |
| tree | 83d78d3d28e094d6a3af347d2ff2ff16472e5421 /src/tokens/packed_binary_literal.rs | |
| parent | 4e8fae09f0f7d6f3a4ddbe285aeb01ef0622b761 (diff) | |
| download | torque-asm-67470aea034fd46f4bbcfe815c51ad3451043188.zip | |
Finish first working version of Torque
This is a huge and messy commit, worked on piecemeal while traveling
and while the language was still being designed.
Diffstat (limited to 'src/tokens/packed_binary_literal.rs')
| -rw-r--r-- | src/tokens/packed_binary_literal.rs | 11 | 
1 files changed, 4 insertions, 7 deletions
| diff --git a/src/tokens/packed_binary_literal.rs b/src/tokens/packed_binary_literal.rs index 1252398..a2720b7 100644 --- a/src/tokens/packed_binary_literal.rs +++ b/src/tokens/packed_binary_literal.rs @@ -2,17 +2,13 @@ use crate::*;  pub struct PackedBinaryLiteral { +    pub source: SourceSpan,      pub value: usize, +    pub bits: usize,      pub fields: Vec<BitField>,      pub errors: Vec<PackedBinaryLiteralParseError>,  } -impl PackedBinaryLiteral { -    pub fn from_str(string: &str, parent: &Tokeniser) -> Self { -        parse_packed_binary_literal(string, parent) -    } -} -  pub struct BitField {      pub name: char,      pub source: SourceSpan, @@ -40,7 +36,8 @@ impl std::fmt::Display for PackedBinaryLiteral {          } else {              let bitcount = (self.value.ilog2() + 1) as usize;              'bit: for i in (0..bitcount).rev() { -                if (i+1) % 4 == 0 { +                let is_first_bit = i+1 == bitcount; +                if !is_first_bit && (i+1) % 4 == 0 {                      write!(f, "_")?;                  }                  for field in &self.fields { | 
