39 lines
644 B
Rust
39 lines
644 B
Rust
pub mod ast;
|
|
pub mod typeck;
|
|
|
|
use std::{path::PathBuf, fs::File, io::Read};
|
|
|
|
use clap::Parser;
|
|
use anyhow::Result;
|
|
use lalrpop_util::lalrpop_mod;
|
|
|
|
lalrpop_mod!(pub grammar);
|
|
|
|
#[derive(Debug, Parser)]
|
|
struct Opt {
|
|
input_file: PathBuf,
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
let opt = Opt::parse();
|
|
|
|
let contents = {
|
|
let mut file = File::open(&opt.input_file)?;
|
|
let mut string = String::new();
|
|
file.read_to_string(&mut string)?;
|
|
string
|
|
};
|
|
|
|
let parser = grammar::ProgramParser::new();
|
|
|
|
let tree = parser.parse(&contents);
|
|
|
|
println!("tree: {tree:?}");
|
|
|
|
// TODO: Distill tree into rules
|
|
|
|
// TODO: Type-checking
|
|
|
|
Ok(())
|
|
}
|