move instructions to its seperate crate

This commit is contained in:
2021-09-20 14:30:53 +02:00
parent 8184d31e4f
commit 9f705f8389
4 changed files with 20 additions and 17 deletions

17
src/instruction.rs Normal file
View File

@@ -0,0 +1,17 @@
#[derive(Debug)]
pub enum InstructionType {
Increment,
Decrement,
Leftshift,
Rightshift,
PutChar,
GetChar,
JumpIfZero,
JumpIfNotZero,
}
#[derive(Debug)]
pub struct Instruction {
pub itype: InstructionType,
pub argument: usize,
}

View File

@@ -1 +1,3 @@
pub mod machine;
pub mod parser;
pub mod instruction;

View File

@@ -1,22 +1,6 @@
use std::io::{BufReader, BufWriter, Read, Write};
#[derive(Debug)]
pub enum InstructionType {
Increment,
Decrement,
Leftshift,
Rightshift,
PutChar,
GetChar,
JumpIfZero,
JumpIfNotZero,
}
#[derive(Debug)]
pub struct Instruction {
pub itype: InstructionType,
pub argument: usize,
}
use crate::instruction::{Instruction, InstructionType};
pub struct Machine<'a> {
ip: usize,

0
src/parser.rs Normal file
View File