34 lines
519 B
Rust
34 lines
519 B
Rust
|
#[macro_use]
|
||
|
extern crate lalrpop_util;
|
||
|
#[macro_use]
|
||
|
extern crate anyhow;
|
||
|
|
||
|
lalrpop_mod!(parser);
|
||
|
|
||
|
mod ast;
|
||
|
|
||
|
use std::fs;
|
||
|
use std::path::PathBuf;
|
||
|
|
||
|
use anyhow::Result;
|
||
|
use clap::Parser;
|
||
|
|
||
|
use crate::parser::ProgramParser;
|
||
|
|
||
|
#[derive(Debug, Parser)]
|
||
|
struct Opt {
|
||
|
path: PathBuf,
|
||
|
}
|
||
|
|
||
|
fn main() -> Result<()> {
|
||
|
let opts = Opt::parse();
|
||
|
|
||
|
let contents = fs::read_to_string(opts.path)?;
|
||
|
|
||
|
let parser = ProgramParser::new();
|
||
|
let ast = parser.parse(&contents).unwrap();
|
||
|
println!("AST: {ast:?}");
|
||
|
|
||
|
Ok(())
|
||
|
}
|