Add lexer dump to main and fix a couple of bugs

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-01-27 19:07:57 -05:00
parent a5388c8b86
commit c4c196a136
3 changed files with 35 additions and 6 deletions

View File

@@ -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(())
}