iowo/crates/lang/src/main.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

2024-04-02 22:08:00 +00:00
use std::{fs, path::PathBuf};
use clap::Parser;
use lang::{
err_reporting::ErrorCollector,
parser::ast::lossless::{
lex,
2024-04-12 18:55:55 +00:00
parser::{self, parse},
},
};
2024-04-02 22:08:00 +00:00
#[derive(Parser)]
struct Args {
file: PathBuf,
}
#[allow(clippy::unwrap_used)]
2024-04-02 22:08:00 +00:00
fn main() {
let args = Args::parse();
let n = args.file.clone();
let f = fs::read_to_string(n.clone()).expect("failed to read file");
println!("toks: {:?}", lex::lex(&f));
2024-04-12 18:55:55 +00:00
println!("parse res: {:?}", parse(&f));
// let parse_res = parser::parse(&f);
// println!("parse: {:?}", parse_res);
// dbg!(lex::lex(&f));
// let mut err_collector = ErrorCollector::new(vec![(n.to_str().unwrap(), &f)]);
2024-04-02 22:08:00 +00:00
// println!("file: {f}\n");
// let parse_res = parse(&f);
// err_collector.insert_many(
// args.file.to_str().unwrap(),
// lang::err_reporting::Stage::Parse,
// parse_res
// .errors()
// .into_iter()
// .map(|e| e.to_owned())
// .collect::<Vec<_>>(),
// );
// err_collector.report_raw();
// println!("res: {:?}", parse_res);
2024-04-02 22:08:00 +00:00
}