Split yunq compliation to library and use it in build process.

This commit is contained in:
Drew Galbraith 2024-07-28 18:08:34 -07:00
parent 370ba9ae40
commit 1e073d5060
7 changed files with 89 additions and 28 deletions

15
yunq/rust/src/lib.rs Normal file
View file

@ -0,0 +1,15 @@
mod codegen;
mod lexer;
mod parser;
use std::error::Error;
pub fn codegen(input: &str) -> Result<String, Box<dyn Error>> {
let tokens = lexer::lex_input(input)?;
let mut ast_parser = parser::Parser::new(&tokens);
ast_parser.parse_ast()?;
ast_parser.type_check()?;
Ok(codegen::generate_code(ast_parser.ast()))
}