Split yunq compliation to library and use it in build process.
This commit is contained in:
parent
370ba9ae40
commit
1e073d5060
7 changed files with 89 additions and 28 deletions
15
yunq/rust/src/lib.rs
Normal file
15
yunq/rust/src/lib.rs
Normal 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()))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue