schala/src/main.rs

66 lines
1.2 KiB
Rust
Raw Normal View History

2015-07-16 02:55:03 -07:00
use std::io;
use std::io::Write;
use std::io::BufRead;
2015-07-16 01:40:37 -07:00
fn main() {
2015-07-16 02:55:03 -07:00
println!("Unnamed language 0.01");
repl();
}
#[derive(Debug)]
enum Token {
EOF,
NumLiteral(i32),
StrLiteral(String),
Identifier(String)
/* Keyword(Keyword) */ //implement in future
}
#[derive(Debug)]
enum ASTNode {
GenericNode
}
fn repl() {
let mut stdin = io::stdin();
let mut stdout = io::stdout();
let mut buf = String::with_capacity(20);
loop {
print!(">> ");
stdout.flush().ok();
let line = stdin.lock().read_line(&mut buf);
match line {
Ok(n) => {
2015-07-18 14:50:26 -07:00
let tokens = tokenize(&buf);
println!("Tokens: {:?}", tokens);
let ast = parse(tokens);
println!("AST: {:?}", ast);
2015-07-16 02:55:03 -07:00
},
Err(err) => {
println!("Error: {}", err);
}
}
}
}
fn tokenize(input: &str) -> Vec<Token> {
let mut tokens = Vec::new();
let mut buffer = String::with_capacity(20);
let mut iterator = input.chars();
loop {
break;
}
tokens.push(Token::EOF);
tokens
}
fn parse(_input: Vec<Token>) -> ASTNode {
ASTNode::GenericNode
2015-07-16 01:40:37 -07:00
}