feat: parse error
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use itertools::Itertools;
|
||||||
use inkwell::context::Context;
|
use inkwell::context::Context;
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::{DefaultEditor, Result};
|
use rustyline::{DefaultEditor, Result};
|
||||||
@@ -5,6 +6,7 @@ use rustyline::{DefaultEditor, Result};
|
|||||||
use nixjit::compile::compile;
|
use nixjit::compile::compile;
|
||||||
use nixjit::ir::downgrade;
|
use nixjit::ir::downgrade;
|
||||||
use nixjit::vm::{run, JITContext};
|
use nixjit::vm::{run, JITContext};
|
||||||
|
use nixjit::error::Error;
|
||||||
|
|
||||||
macro_rules! unwrap {
|
macro_rules! unwrap {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
@@ -28,9 +30,13 @@ fn main() -> Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rl.add_history_entry(expr.as_str())?;
|
rl.add_history_entry(expr.as_str())?;
|
||||||
let downgraded = unwrap!(downgrade(
|
let root = rnix::Root::parse(&expr);
|
||||||
rnix::Root::parse(expr.as_str()).tree().expr().unwrap()
|
if !root.errors().is_empty() {
|
||||||
));
|
println!("{}", Error::ParseError(root.errors().iter().map(|err| err.to_string()).join(";")));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let expr = root.tree().expr().unwrap();
|
||||||
|
let downgraded = unwrap!(downgrade(expr));
|
||||||
let prog = compile(downgraded);
|
let prog = compile(downgraded);
|
||||||
let ctx = Context::create();
|
let ctx = Context::create();
|
||||||
let jit = JITContext::new(&ctx);
|
let jit = JITContext::new(&ctx);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ pub type Result<T> = core::result::Result<T, Error>;
|
|||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
#[error("error occurred during parse stage: {0}")]
|
||||||
|
ParseError(String),
|
||||||
#[error("error occurred during downgrade stage: {0}")]
|
#[error("error occurred during downgrade stage: {0}")]
|
||||||
DowngradeError(String),
|
DowngradeError(String),
|
||||||
#[error("error occurred during evaluation stage: {0}")]
|
#[error("error occurred during evaluation stage: {0}")]
|
||||||
|
|||||||
Reference in New Issue
Block a user