sandwich

A funny programming language written in Rust
git clone https://tilde.team/~karx/sandwich.git
Log | Files | Refs | README | LICENSE

commit 15aa81056496e7643d928e89cb35a28e88458a00
parent dc4efa3aa6dedf9121791366c02b6b6941a53612
Author: Yash <nerdstep710@gmail.com>
Date:   Wed,  3 Feb 2021 15:54:13 -0600

Iterate through program

Diffstat:
Msrc/main.rs | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,10 +1,11 @@ use std::fs; use std::env; use std::fmt; +use std::usize; struct Program { data: Vec<String>, - pc: u32 + pc: usize } impl Program { @@ -22,8 +23,15 @@ impl Program { return Program{ data: op_list, pc: 0 }; } - fn run(&self) { + fn run(&mut self) { println!("{}", self); + while self.pc < self.data.len() { + println!("PC is {}", self.pc); + let opcode = &self.data[self.pc]; + + + self.pc = self.pc + 1; + } } } @@ -43,6 +51,6 @@ fn main() { let filename = &args[1]; let contents = fs::read_to_string(filename).expect("Something went wrong reading the file"); - let prog = Program::from_string(contents); + let mut prog = Program::from_string(contents); prog.run(); }