Website Summary Files Commits Branches @commit @diff @stats
path: root / assembler / src / parser
diff options
context:
space:
mode:
1 files changed, 10 insertions, 11 deletions
-rw-r--r--assembler/src/parser/mod.rs21
diff --git a/assembler/src/parser/mod.rs b/assembler/src/parser/mod.rs
index d43b9c5..f93875b 100644
--- a/assembler/src/parser/mod.rs
+++ b/assembler/src/parser/mod.rs
@@ -16,25 +16,24 @@ pub(crate) struct Program {
instructions: Vec<Instruction>,
}
-impl Display for Program {
- fn fmt(&self, f: &mut Formatter) -> Result {
- writeln!(f, "-- Definitions --")?;
+impl Program {
+ pub(crate) fn print(&self, start_index: usize) {
+ println!("-- Definitions --");
for (name, loc) in self.definitions.iter() {
- writeln!(f, "{} := {:?}", name, loc)?;
+ println!("{} := {:?}", name, loc);
}
- writeln!(f, "-- Constants --")?;
+ println!("-- Constants --");
for (i, cnst) in self.constants.iter().enumerate() {
- writeln!(f, "{: >8}: {} ", i, cnst)?;
+ println!("{: >8}: {} ", i + start_index, cnst);
}
- writeln!(f, "-- Instructions --")?;
+ println!("-- Instructions --");
for (i, instr) in self.instructions.iter().enumerate() {
- write!(f, "{: >8}: {} ", i, instr.name)?;
+ print!("{: >8}: {} ", i + start_index, instr.name);
for arg in &instr.args {
- write!(f, "{:?}, ", arg)?;
+ print!("{:?}, ", arg);
}
- writeln!(f, "")?;
+ println!("");
}
- Ok(())
}
}