Create a first pass at a rust parser for the yunq language.

This commit is contained in:
Drew Galbraith 2024-06-11 13:01:58 -07:00
parent 5b1debde54
commit 1cda053758
6 changed files with 793 additions and 0 deletions

30
yunq/rust/src/main.rs Normal file
View file

@ -0,0 +1,30 @@
mod lexer;
mod parser;
use std::error::Error;
use std::fs::read_to_string;
use clap::Parser;
#[derive(Parser)]
#[command(about)]
struct Args {
// The .yunq file to parse
#[arg(short, long)]
input_path: String,
}
fn main() -> Result<(), Box<dyn Error>> {
let args = Args::parse();
let input = read_to_string(args.input_path)?;
let tokens = lexer::lex_input(&input)?;
let mut ast_parser = parser::Parser::new(&tokens);
ast_parser.parse_ast()?;
for decl in ast_parser.ast() {
println!("{:?}", decl);
}
Ok(())
}