1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#[cfg(test)]
#[path = "./mod_test.rs"]
mod mod_test;
mod include_files_preprocessor;
mod print_preprocessor;
use crate::types::error::{ErrorInfo, ScriptError};
use crate::types::instruction::{Instruction, InstructionType};
pub(crate) fn run(instruction: &Instruction) -> Result<Vec<Instruction>, ScriptError> {
match instruction.instruction_type {
InstructionType::PreProcess(ref instruction_type) => match &instruction_type.command {
Some(command) => match command.as_ref() {
"print" => {
print_preprocessor::run(&instruction_type.arguments);
Ok(vec![])
}
"include_files" => include_files_preprocessor::run(
&instruction_type.arguments,
&instruction.meta_info,
),
_ => Err(ScriptError {
info: ErrorInfo::UnknownPreProcessorCommand(instruction.meta_info.clone()),
}),
},
None => Err(ScriptError {
info: ErrorInfo::PreProcessNoCommandFound(instruction.meta_info.clone()),
}),
},
_ => Ok(vec![]),
}
}