mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-13 01:35:31 +01:00
Step 1: Create an AST
This step consists of creating the AST to represent the input
expression, the only evaluation done for now is the recognition of three
MalTypes for the nodes of the AST:
- Symbols: atomic isolated groups of characters
- Integers: Symbols that can be parsed as number and are treated as so
- Lists: recognizable by the presence of parentheses (only "()" for now,
"[]" and "{}" later), these can contain any number of MalTypes
The second half of this step (much easier) is to reconstruct the
original syntax (with clean whitespaces) to check the correctness of the
process
Signed-off-by: teo3300 <matteo.rogora@live.it>
This commit is contained in:
10
src/main.rs
10
src/main.rs
@ -1,8 +1,12 @@
|
||||
// io lib to read input and print output
|
||||
use std::io::{self, Write};
|
||||
|
||||
mod step0_repl;
|
||||
use step0_repl::rep;
|
||||
mod printer;
|
||||
mod reader;
|
||||
mod types;
|
||||
|
||||
mod step1_read_print;
|
||||
use step1_read_print::rep;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
loop {
|
||||
@ -14,6 +18,6 @@ fn main() -> io::Result<()> {
|
||||
|
||||
io::stdin().read_line(&mut input)?;
|
||||
|
||||
print!("{}", rep(&input));
|
||||
println!("{}", rep(&input.replace("\n", " ")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user