2024-04-24 11:07:38 +02:00
|
|
|
use clap::Parser;
|
2024-04-03 00:08:00 +02:00
|
|
|
use std::{fs, path::PathBuf};
|
|
|
|
|
2024-04-24 11:09:48 +02:00
|
|
|
use lang::parser::{self, grammar, input, output::Output, syntax_kind};
|
2024-04-03 00:08:00 +02:00
|
|
|
|
|
|
|
#[derive(Parser)]
|
|
|
|
struct Args {
|
|
|
|
file: PathBuf,
|
|
|
|
}
|
|
|
|
|
2024-04-03 17:00:20 +02:00
|
|
|
#[allow(clippy::unwrap_used)]
|
2024-04-03 00:08:00 +02:00
|
|
|
fn main() {
|
|
|
|
let args = Args::parse();
|
2024-04-03 17:00:20 +02:00
|
|
|
let n = args.file.clone();
|
|
|
|
let f = fs::read_to_string(n.clone()).expect("failed to read file");
|
2024-04-24 11:07:38 +02:00
|
|
|
|
|
|
|
let toks = dbg!(syntax_kind::lex(&f));
|
|
|
|
let input = input::Input::new(&toks);
|
|
|
|
let mut parser = parser::Parser::new(input);
|
|
|
|
|
|
|
|
grammar::source_file(&mut parser);
|
|
|
|
|
|
|
|
let p_out = dbg!(parser.finish());
|
|
|
|
let o = Output::from_parser_output(toks, p_out);
|
|
|
|
|
|
|
|
println!("Out: {:?}", o);
|
2024-04-12 15:43:34 +02:00
|
|
|
|
|
|
|
// let parse_res = parser::parse(&f);
|
|
|
|
// println!("parse: {:?}", parse_res);
|
|
|
|
|
2024-04-11 03:23:03 +02:00
|
|
|
// dbg!(lex::lex(&f));
|
|
|
|
// let mut err_collector = ErrorCollector::new(vec![(n.to_str().unwrap(), &f)]);
|
2024-04-03 00:08:00 +02:00
|
|
|
|
2024-04-11 03:23:03 +02: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<_>>(),
|
|
|
|
// );
|
2024-04-03 17:00:20 +02:00
|
|
|
|
2024-04-11 03:23:03 +02:00
|
|
|
// err_collector.report_raw();
|
|
|
|
// println!("res: {:?}", parse_res);
|
2024-04-03 00:08:00 +02:00
|
|
|
}
|