feat: parse error
This commit is contained in:
@@ -1,8 +1,15 @@
|
|||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
mod compile;
|
mod compile;
|
||||||
mod ir;
|
mod ir;
|
||||||
|
|
||||||
pub fn compile(expr: &str) -> anyhow::Result<crate::bytecode::Program> {
|
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)?;
|
let ir = ir::downgrade(expr)?;
|
||||||
Ok(compile::compile(ir))
|
Ok(compile::compile(ir))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user