mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 17:25:33 +01:00
Step 0 alone only act as an echo for the input, define the sructure of the interpreter Signed-off-by: teo3300 <matteo.rogora@live.it>
30 lines
708 B
Rust
30 lines
708 B
Rust
// Structure the main functions of the interpreter
|
|
//
|
|
// For now just act as an echo, note that each function should not modify the
|
|
// input, thus this can be referenced by the previous step without the need
|
|
// to allocate more memory
|
|
|
|
#[allow(non_snake_case)]
|
|
/// Read input and generate an ast
|
|
fn READ(input: &str) -> String {
|
|
input.to_string()
|
|
}
|
|
|
|
#[allow(non_snake_case)]
|
|
/// Evaluate the generated ast
|
|
fn EVAL(input: &str) -> String {
|
|
input.to_string()
|
|
}
|
|
|
|
#[allow(non_snake_case)]
|
|
/// Print out the result of the evaluation
|
|
fn PRINT(input: &str) -> String {
|
|
input.to_string()
|
|
}
|
|
|
|
pub fn rep(input: &str) -> String {
|
|
let ast = READ(input);
|
|
let result = EVAL(&ast);
|
|
PRINT(&result)
|
|
}
|