iowo/crates/lang/src/main.rs

33 lines
717 B
Rust
Raw Normal View History

2024-04-24 09:07:38 +00:00
use clap::Parser;
2024-04-02 22:08:00 +00:00
use std::{fs, path::PathBuf};
2024-06-05 16:00:14 +00:00
use lang::{
ast::World,
lst_parser::{self, grammar, input, output::Output, syntax_kind},
};
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");
2024-04-24 09:07:38 +00: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 09:07:38 +00:00
grammar::source_file(&mut parser);
2024-04-24 09:07:38 +00:00
let p_out = dbg!(parser.finish());
let o = Output::from_parser_output(toks, p_out);
2024-04-24 09:07:38 +00:00
println!("{}", o.debug_colored());
// World::new(n);
2024-04-02 22:08:00 +00:00
}