Add lexer dump to main and fix a couple of bugs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -2,6 +2,29 @@ mod common;
|
||||
//mod syn;
|
||||
mod vm;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use std::{
|
||||
io::{self, Read},
|
||||
process,
|
||||
};
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
fn get_input_string() -> io::Result<String> {
|
||||
let mut buffer = String::new();
|
||||
io::stdin().read_to_string(&mut buffer)?;
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
use vm::syn::parser::ProgramParser;
|
||||
let contents = get_input_string()?;
|
||||
let ast = match ProgramParser::new().parse(&contents) {
|
||||
Ok(ast) => ast,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
process::exit(1);
|
||||
},
|
||||
};
|
||||
println!("{:?}", ast);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user