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-06-23 20:53:05 +02:00
|
|
|
use lang::lst_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();
|
2024-06-10 09:47:48 +02:00
|
|
|
let f = fs::read_to_string(n.clone()).expect("failed to read file");
|
2024-04-24 11:07:38 +02:00
|
|
|
|
2024-06-10 09:47:48 +02:00
|
|
|
let toks = dbg!(syntax_kind::lex(&f));
|
|
|
|
let input = input::Input::new(&toks);
|
|
|
|
let mut parser = lst_parser::Parser::new(input);
|
2024-04-24 11:07:38 +02:00
|
|
|
|
2024-06-10 09:47:48 +02:00
|
|
|
grammar::source_file(&mut parser);
|
2024-04-24 11:07:38 +02:00
|
|
|
|
2024-06-10 09:47:48 +02:00
|
|
|
let p_out = dbg!(parser.finish());
|
|
|
|
let o = Output::from_parser_output(toks, p_out);
|
2024-04-24 11:07:38 +02:00
|
|
|
|
2024-06-10 09:47:48 +02:00
|
|
|
println!("{}", o.debug_colored());
|
2024-04-12 15:43:34 +02:00
|
|
|
|
2024-06-10 09:47:48 +02:00
|
|
|
// World::new(n);
|
2024-04-03 00:08:00 +02:00
|
|
|
}
|