Skip to content

Commit

Permalink
Don't skip the first token after a newline with next_ignore_newline
Browse files Browse the repository at this point in the history
  • Loading branch information
chorman0773 committed Oct 5, 2024
1 parent c172cf0 commit fecf4f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lcas/src/as_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ pub trait PeekToken: Iterator {
Self: Iterator<Item = Spanned<Token>>,
{
loop {
match self.next()? {
match dbg!(self.next()?) {
tok if matches!(tok.body(), Token::LineTerminator) => {
self.next();
continue;
}
tok => break Some(tok),
Expand Down Expand Up @@ -96,8 +95,9 @@ impl<'a> Assembler<'a> {

loop {
let maybe_mnemonic = self.state.iter.next_ignore_newline()?;
match maybe_mnemonic.into_inner() {
Token::Identifier(id) => match self.state.iter.peek()?.body() {

match dbg!(maybe_mnemonic).into_inner() {
Token::Identifier(id) => match dbg!(self.state.iter.peek())?.body() {
Token::Sigil(x) if x == ":" => {
self.state.iter.next();
self.as_callbacks.create_symbol_now(self, &id)
Expand Down
2 changes: 2 additions & 0 deletions lcas/src/lcas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ impl AssemblerCallbacks for Callbacks {

asm.set_output(Box::new(SharedSection(sect)));

dbg!(asm.iter().peek());

Ok(())
}
tok => panic!(
Expand Down
4 changes: 2 additions & 2 deletions lcas/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ impl Pos {
self.0 >> 20
}

pub const fn next_col(mut self, n: u32) -> Self {
pub const fn next_col(self, n: u32) -> Self {
Self::new(self.row(), self.col() + n)
}

pub const fn next_row(mut self, n: u32) -> Self {
pub const fn next_row(self, n: u32) -> Self {
Self::new(self.row() + n, 0)
}
}
Expand Down
2 changes: 0 additions & 2 deletions lcas/src/targ.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::any::Any;

use arch_ops::traits::InsnWrite;

use crate::as_state::AsState;

use target_tuples::Architecture;
Expand Down

0 comments on commit fecf4f4

Please sign in to comment.