sandwich

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

commit 1fb0530a1335d473fdc3b9a7b6eb59f099a653f8
parent 15aa81056496e7643d928e89cb35a28e88458a00
Author: Yash <nerdstep710@gmail.com>
Date:   Wed,  3 Feb 2021 16:04:58 -0600

Implement print functionality

Diffstat:
Minp.txt | 2+-
Msrc/main.rs | 10++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/inp.txt b/inp.txt @@ -1 +1 @@ -Test file +pH pe pl pl po p, pW po pr pl pd p! diff --git a/src/main.rs b/src/main.rs @@ -26,8 +26,14 @@ impl Program { fn run(&mut self) { println!("{}", self); while self.pc < self.data.len() { - println!("PC is {}", self.pc); - let opcode = &self.data[self.pc]; + let instruction = &self.data[self.pc]; + let instruction_vec: Vec<char> = instruction.chars().collect(); + let opcode = instruction_vec[0]; + + match opcode { + 'p' => print!("{}", instruction_vec[1]), + _ => panic!("SyntaxError at opcode {}!", self.pc) + } self.pc = self.pc + 1;