feat: parse error
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
use itertools::Itertools;
|
||||
|
||||
mod compile;
|
||||
mod ir;
|
||||
|
||||
pub fn compile(expr: &str) -> anyhow::Result<crate::bytecode::Program> {
|
||||
let expr = rnix::Root::parse(expr).tree().expr().unwrap();
|
||||
let root = rnix::Root::parse(expr);
|
||||
if !root.errors().is_empty() {
|
||||
return Err(anyhow::anyhow!(root.errors().iter().map(|err| err.to_string()).join(";")))
|
||||
}
|
||||
assert!(root.errors().is_empty());
|
||||
let expr = root.tree().expr().unwrap();
|
||||
let ir = ir::downgrade(expr)?;
|
||||
Ok(compile::compile(ir))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user