From 7f566782e3e87e5e9fc009cf972eeb92fbb5ef63 Mon Sep 17 00:00:00 2001 From: howardwu Date: Sat, 6 Jun 2020 23:23:26 -0700 Subject: [PATCH] Refactors SyntaxError to leo-ast --- Cargo.lock | 2 ++ ast/Cargo.toml | 4 +++- ast/src/errors/mod.rs | 2 ++ .../src/errors/ast/mod.rs => ast/src/errors/syntax.rs | 2 +- ast/src/lib.rs | 9 +++++---- compiler/src/errors/compiler.rs | 4 ++-- compiler/src/errors/mod.rs | 3 --- 7 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 ast/src/errors/mod.rs rename compiler/src/errors/ast/mod.rs => ast/src/errors/syntax.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index c8f951ffbc..3a3f6a4841 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,9 +503,11 @@ version = "0.1.0" dependencies = [ "from-pest", "lazy_static", + "log", "pest", "pest-ast", "pest_derive", + "thiserror", ] [[package]] diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 56f82f68d2..6e243e49d0 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -1,12 +1,14 @@ [package] name = "leo-ast" version = "0.1.0" -authors = ["howardwu "] +authors = ["The Aleo Team "] edition = "2018" [dependencies] from-pest = { version = "0.3.1" } lazy_static = { version = "1.3.0" } +log = { version = "0.4" } pest = { version = "2.0" } pest-ast = { version = "0.3.3" } pest_derive = { version = "2.0" } +thiserror = { version = "1.0" } diff --git a/ast/src/errors/mod.rs b/ast/src/errors/mod.rs new file mode 100644 index 0000000000..bd7f83eec7 --- /dev/null +++ b/ast/src/errors/mod.rs @@ -0,0 +1,2 @@ +pub mod syntax; +pub use syntax::*; diff --git a/compiler/src/errors/ast/mod.rs b/ast/src/errors/syntax.rs similarity index 98% rename from compiler/src/errors/ast/mod.rs rename to ast/src/errors/syntax.rs index 6ec6770f95..cf3c7c30d1 100644 --- a/compiler/src/errors/ast/mod.rs +++ b/ast/src/errors/syntax.rs @@ -1,4 +1,4 @@ -use leo_ast::ast::Rule; +use crate::ast::Rule; use pest::error::Error; diff --git a/ast/src/lib.rs b/ast/src/lib.rs index 57e14bf364..3d9955dfe9 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -2,10 +2,11 @@ extern crate lazy_static; #[macro_use] extern crate pest_derive; - -extern crate from_pest; -extern crate pest; -extern crate pest_ast; +#[macro_use] +extern crate thiserror; pub mod ast; pub use ast::*; + +pub mod errors; +pub use errors::*; diff --git a/compiler/src/errors/compiler.rs b/compiler/src/errors/compiler.rs index f099bbf374..d444ffbdeb 100644 --- a/compiler/src/errors/compiler.rs +++ b/compiler/src/errors/compiler.rs @@ -1,5 +1,5 @@ -use crate::errors::{FunctionError, ImportError, IntegerError, SyntaxError}; -use leo_ast::ast::Rule; +use crate::errors::{FunctionError, ImportError, IntegerError, }; +use leo_ast::{ast::Rule, SyntaxError}; use pest::error::Error; use std::{io, path::PathBuf}; diff --git a/compiler/src/errors/mod.rs b/compiler/src/errors/mod.rs index 88012d2939..91d6712541 100644 --- a/compiler/src/errors/mod.rs +++ b/compiler/src/errors/mod.rs @@ -1,6 +1,3 @@ -pub mod ast; -pub use self::ast::*; - pub mod compiler; pub use self::compiler::*;