Skip to content

Commit

Permalink
Move InstructionType to another file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sellig6792 committed Dec 27, 2022
1 parent f62420b commit 4d21e3f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
7 changes: 5 additions & 2 deletions src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub mod instructions;
pub mod parser;
mod instructions;
mod parser;
mod instruction_types;

pub use parser::Parser;
pub use instructions::{InstructionTrait, Instruction};
pub use instruction_types::InstructionType;
21 changes: 21 additions & 0 deletions src/ast/instruction_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#[derive(Debug, Clone, PartialEq)]
pub enum InstructionType {
Increment,
Decrement,

MoveLeft,
MoveRight,

Input,
Output,

Loop,

Function,
CallFunction,

MoveLeftScope,
MoveRightScope,

Random,
}
22 changes: 1 addition & 21 deletions src/ast/instructions.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
#[derive(Debug, Clone, PartialEq)]
pub enum InstructionType {
Increment,
Decrement,

MoveLeft,
MoveRight,

Input,
Output,

Loop,

Function,
CallFunction,

MoveLeftScope,
MoveRightScope,

Random,
}
use crate::ast::InstructionType;

pub trait InstructionTrait<T> {
fn new(instruction_type: InstructionType, content: Option<Vec<T>>) -> Self;
Expand Down
2 changes: 1 addition & 1 deletion src/ast/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::instructions::{Instruction, InstructionType};
use crate::ast::{Instruction, InstructionType};

pub struct Parser {
program: String,
Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/evaluator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rand::Rng;

use crate::ast::instructions::{InstructionTrait, InstructionType};
use crate::ast::{InstructionTrait, InstructionType};

use crate::evaluation::{Cell, Scopes};

Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/scope.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::instructions::{InstructionTrait, InstructionType};
use crate::ast::{InstructionTrait, InstructionType};

use crate::evaluation::Cell;

Expand Down
2 changes: 1 addition & 1 deletion src/optimization/optimized_instructions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::instructions::{InstructionTrait, InstructionType};
use crate::ast::{InstructionTrait, InstructionType};

#[derive(Clone)]
pub struct OptimizedInstruction {
Expand Down
2 changes: 1 addition & 1 deletion src/optimization/optimizer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::instructions::{Instruction, InstructionTrait, InstructionType};
use crate::ast::{Instruction, InstructionTrait, InstructionType};

use crate::optimization::optimized_instructions::OptimizedInstruction;

Expand Down

0 comments on commit 4d21e3f

Please sign in to comment.