mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 18:21:38 +03:00
rename core-ast -> ast
This commit is contained in:
parent
ffcd93f781
commit
a8c5885836
42
Cargo.lock
generated
42
Cargo.lock
generated
@ -1229,13 +1229,27 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "leo-ast"
|
||||||
|
version = "1.0.3"
|
||||||
|
dependencies = [
|
||||||
|
"criterion",
|
||||||
|
"leo-grammar",
|
||||||
|
"leo-input",
|
||||||
|
"pest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"snarkos-errors",
|
||||||
|
"snarkos-models",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "leo-compiler"
|
name = "leo-compiler"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"hex",
|
"hex",
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-core-packages",
|
"leo-core-packages",
|
||||||
"leo-gadgets",
|
"leo-gadgets",
|
||||||
"leo-grammar",
|
"leo-grammar",
|
||||||
@ -1264,25 +1278,11 @@ dependencies = [
|
|||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "leo-core-ast"
|
|
||||||
version = "1.0.3"
|
|
||||||
dependencies = [
|
|
||||||
"criterion",
|
|
||||||
"leo-grammar",
|
|
||||||
"leo-input",
|
|
||||||
"pest",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"snarkos-errors",
|
|
||||||
"snarkos-models",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "leo-core-packages"
|
name = "leo-core-packages"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-gadgets",
|
"leo-gadgets",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_xorshift",
|
"rand_xorshift",
|
||||||
@ -1327,7 +1327,7 @@ dependencies = [
|
|||||||
name = "leo-imports"
|
name = "leo-imports"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-grammar",
|
"leo-grammar",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tracing",
|
"tracing",
|
||||||
@ -1362,8 +1362,8 @@ dependencies = [
|
|||||||
"env_logger 0.8.1",
|
"env_logger 0.8.1",
|
||||||
"from-pest",
|
"from-pest",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"leo-ast",
|
||||||
"leo-compiler",
|
"leo-compiler",
|
||||||
"leo-core-ast",
|
|
||||||
"leo-gadgets",
|
"leo-gadgets",
|
||||||
"leo-imports",
|
"leo-imports",
|
||||||
"leo-input",
|
"leo-input",
|
||||||
@ -1414,7 +1414,7 @@ dependencies = [
|
|||||||
name = "leo-state"
|
name = "leo-state"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-input",
|
"leo-input",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_xorshift",
|
"rand_xorshift",
|
||||||
@ -1433,7 +1433,7 @@ dependencies = [
|
|||||||
name = "leo-symbol-table"
|
name = "leo-symbol-table"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-core-packages",
|
"leo-core-packages",
|
||||||
"leo-grammar",
|
"leo-grammar",
|
||||||
"leo-imports",
|
"leo-imports",
|
||||||
@ -1445,7 +1445,7 @@ dependencies = [
|
|||||||
name = "leo-type-inference"
|
name = "leo-type-inference"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leo-core-ast",
|
"leo-ast",
|
||||||
"leo-grammar",
|
"leo-grammar",
|
||||||
"leo-imports",
|
"leo-imports",
|
||||||
"leo-symbol-table",
|
"leo-symbol-table",
|
||||||
|
10
Cargo.toml
10
Cargo.toml
@ -26,8 +26,8 @@ path = "leo/main.rs"
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"ast",
|
||||||
"compiler",
|
"compiler",
|
||||||
"core-ast",
|
|
||||||
"core-packages",
|
"core-packages",
|
||||||
"gadgets",
|
"gadgets",
|
||||||
"grammar",
|
"grammar",
|
||||||
@ -40,12 +40,12 @@ members = [
|
|||||||
"type-inference",
|
"type-inference",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies.leo-compiler]
|
[dependencies.leo-ast]
|
||||||
path = "./compiler"
|
path = "./ast"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
||||||
[dependencies.leo-core-ast]
|
[dependencies.leo-compiler]
|
||||||
path = "./core-ast"
|
path = "./compiler"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
||||||
[dependencies.leo-gadgets]
|
[dependencies.leo-gadgets]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "leo-core-ast"
|
name = "leo-ast"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
authors = [ "The Aleo Team <hello@aleo.org>" ]
|
||||||
description = "Core AST of the Leo programming language"
|
description = "Core AST of the Leo programming language"
|
||||||
@ -18,12 +18,12 @@ license = "GPL-3.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "leo_core_ast"
|
name = "leo_ast"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "core_ast"
|
name = "leo_ast"
|
||||||
path = "benches/core_ast.rs"
|
path = "benches/leo_ast.rs"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[dependencies.leo-grammar]
|
[dependencies.leo-grammar]
|
@ -14,14 +14,14 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::LeoCoreAst;
|
use leo_ast::LeoAst;
|
||||||
use leo_grammar::Grammar;
|
use leo_grammar::Grammar;
|
||||||
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use std::{path::Path, time::Duration};
|
use std::{path::Path, time::Duration};
|
||||||
|
|
||||||
fn leo_core_ast<'ast>(ast: &Grammar<'ast>) -> LeoCoreAst {
|
fn leo_ast<'ast>(ast: &Grammar<'ast>) -> LeoAst {
|
||||||
LeoCoreAst::new("leo_core_tree", &ast)
|
LeoAst::new("leo_core_tree", &ast)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_big_if_else(c: &mut Criterion) {
|
fn bench_big_if_else(c: &mut Criterion) {
|
||||||
@ -29,7 +29,7 @@ fn bench_big_if_else(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./big_if_else.leo");
|
let program_string = include_str!("./big_if_else.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::big_if_else", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::big_if_else", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_big_ternary(c: &mut Criterion) {
|
fn bench_big_ternary(c: &mut Criterion) {
|
||||||
@ -37,7 +37,7 @@ fn bench_big_ternary(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./big_ternary.leo");
|
let program_string = include_str!("./big_ternary.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::big_ternary", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::big_ternary", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_big_circuit(c: &mut Criterion) {
|
fn bench_big_circuit(c: &mut Criterion) {
|
||||||
@ -45,7 +45,7 @@ fn bench_big_circuit(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./big_circuit.leo");
|
let program_string = include_str!("./big_circuit.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::big_circuit", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::big_circuit", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_long_expr(c: &mut Criterion) {
|
fn bench_long_expr(c: &mut Criterion) {
|
||||||
@ -53,7 +53,7 @@ fn bench_long_expr(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./long_expr.leo");
|
let program_string = include_str!("./long_expr.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::long_expr", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::long_expr", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_long_array(c: &mut Criterion) {
|
fn bench_long_array(c: &mut Criterion) {
|
||||||
@ -61,7 +61,7 @@ fn bench_long_array(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./long_array.leo");
|
let program_string = include_str!("./long_array.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::long_array", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::long_array", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_many_foos(c: &mut Criterion) {
|
fn bench_many_foos(c: &mut Criterion) {
|
||||||
@ -69,7 +69,7 @@ fn bench_many_foos(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./many_foos.leo");
|
let program_string = include_str!("./many_foos.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::many_foos", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::many_foos", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_many_assigns(c: &mut Criterion) {
|
fn bench_many_assigns(c: &mut Criterion) {
|
||||||
@ -77,7 +77,7 @@ fn bench_many_assigns(c: &mut Criterion) {
|
|||||||
let program_string = include_str!("./many_assigns.leo");
|
let program_string = include_str!("./many_assigns.leo");
|
||||||
let ast = Grammar::new(&filepath, program_string).unwrap();
|
let ast = Grammar::new(&filepath, program_string).unwrap();
|
||||||
|
|
||||||
c.bench_function("LeoCoreAst::many_assigns", |b| b.iter(|| leo_core_ast(&ast)));
|
c.bench_function("LeoAst::many_assigns", |b| b.iter(|| leo_ast(&ast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(
|
criterion_group!(
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
//! The core abstract syntax tree (ast) for a Leo program.
|
//! The core abstract syntax tree (ast) for a Leo program.
|
||||||
//!
|
//!
|
||||||
//! This module contains the [`LeoCoreAst`] type, a wrapper around the [`Program`] type.
|
//! This module contains the [`LeoAst`] type, a wrapper around the [`Program`] type.
|
||||||
//! The [`LeoCoreAst`] type is intended to be parsed and modified by different passes
|
//! The [`LeoAst`] type is intended to be parsed and modified by different passes
|
||||||
//! of the Leo compiler. The Leo compiler can generate a set of R1CS constraints from any [`LeoCoreAst`].
|
//! of the Leo compiler. The Leo compiler can generate a set of R1CS constraints from any [`LeoAst`].
|
||||||
|
|
||||||
pub mod annotation;
|
pub mod annotation;
|
||||||
pub use self::annotation::*;
|
pub use self::annotation::*;
|
||||||
@ -63,36 +63,36 @@ use leo_grammar::Grammar;
|
|||||||
|
|
||||||
/// The core abstract syntax tree (ast) for a Leo program.
|
/// The core abstract syntax tree (ast) for a Leo program.
|
||||||
///
|
///
|
||||||
/// The [`LeoCoreAst`] type represents a Leo program as a series of recursive data types.
|
/// The [`LeoAst`] type represents a Leo program as a series of recursive data types.
|
||||||
/// These data types form a tree that begins from a [`Program`] type root.
|
/// These data types form a tree that begins from a [`Program`] type root.
|
||||||
///
|
///
|
||||||
/// A new [`LeoCoreAst`] can be created from a [`LeoAst`] generated by the pest parser in the `ast` module.
|
/// A new [`LeoAst`] can be created from a [`Grammar`] generated by the pest parser in the `ast` module.
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct LeoCoreAst {
|
pub struct LeoAst {
|
||||||
core_ast: Program,
|
ast: Program,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LeoCoreAst {
|
impl LeoAst {
|
||||||
/// Creates a new core syntax tree from a given program name and abstract syntax tree.
|
/// Creates a new core syntax tree from a given program name and abstract syntax tree.
|
||||||
pub fn new<'ast>(program_name: &str, ast: &Grammar<'ast>) -> Self {
|
pub fn new<'ast>(program_name: &str, ast: &Grammar<'ast>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
core_ast: Program::from(program_name, ast.as_repr()),
|
ast: Program::from(program_name, ast.as_repr()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the inner program syntax tree representation.
|
/// Returns a reference to the inner program syntax tree representation.
|
||||||
pub fn into_repr(self) -> Program {
|
pub fn into_repr(self) -> Program {
|
||||||
self.core_ast
|
self.ast
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serializes the core syntax tree into a JSON string.
|
/// Serializes the core syntax tree into a JSON string.
|
||||||
pub fn to_json_string(&self) -> Result<String, serde_json::Error> {
|
pub fn to_json_string(&self) -> Result<String, serde_json::Error> {
|
||||||
Ok(serde_json::to_string_pretty(&self.core_ast)?)
|
Ok(serde_json::to_string_pretty(&self.ast)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserializes the JSON string into a core syntax tree.
|
/// Deserializes the JSON string into a core syntax tree.
|
||||||
pub fn from_json_string(json: &str) -> Result<Self, serde_json::Error> {
|
pub fn from_json_string(json: &str) -> Result<Self, serde_json::Error> {
|
||||||
let typed_ast: Program = serde_json::from_str(json)?;
|
let typed_ast: Program = serde_json::from_str(json)?;
|
||||||
Ok(Self { core_ast: typed_ast })
|
Ok(Self { ast: typed_ast })
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::LeoCoreAst;
|
use leo_ast::LeoAst;
|
||||||
use leo_grammar::{Grammar, ParserError};
|
use leo_grammar::{Grammar, ParserError};
|
||||||
use std::{env, fs, path::Path};
|
use std::{env, fs, path::Path};
|
||||||
|
|
||||||
@ -27,10 +27,10 @@ fn to_leo_core_tree(filepath: &Path) -> Result<String, ParserError> {
|
|||||||
let ast = Grammar::new(&program_filepath, &program_string)?;
|
let ast = Grammar::new(&program_filepath, &program_string)?;
|
||||||
|
|
||||||
// Parse the pest ast and constructs a core ast.
|
// Parse the pest ast and constructs a core ast.
|
||||||
let core_ast = LeoCoreAst::new("leo_core_tree", &ast);
|
let core_ast = LeoAst::new("leo_core_tree", &ast);
|
||||||
|
|
||||||
// Serializes the core tree into JSON format.
|
// Serializes the core tree into JSON format.
|
||||||
let serialized_core_ast = LeoCoreAst::to_json_string(&core_ast)?;
|
let serialized_core_ast = LeoAst::to_json_string(&core_ast)?;
|
||||||
|
|
||||||
Ok(serialized_core_ast)
|
Ok(serialized_core_ast)
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ fn main() -> Result<(), ParserError> {
|
|||||||
if cli_arguments.len() < 2 || cli_arguments.len() > 3 {
|
if cli_arguments.len() < 2 || cli_arguments.len() > 3 {
|
||||||
eprintln!("Warning - an invalid number of command-line arguments were provided.");
|
eprintln!("Warning - an invalid number of command-line arguments were provided.");
|
||||||
println!(
|
println!(
|
||||||
"\nCommand-line usage:\n\n\tleo_core_ast {{PATH/TO/INPUT_FILENAME}}.leo {{PATH/TO/OUTPUT_DIRECTORY (optional)}}\n"
|
"\nCommand-line usage:\n\n\tleo_ast {{PATH/TO/INPUT_FILENAME}}.leo {{PATH/TO/OUTPUT_DIRECTORY (optional)}}\n"
|
||||||
);
|
);
|
||||||
return Ok(()); // Exit innocently
|
return Ok(()); // Exit innocently
|
||||||
}
|
}
|
@ -14,14 +14,14 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::LeoCoreAst;
|
use leo_ast::LeoAst;
|
||||||
#[cfg(not(feature = "ci_skip"))]
|
#[cfg(not(feature = "ci_skip"))]
|
||||||
use leo_core_ast::Program;
|
use leo_ast::Program;
|
||||||
use leo_grammar::Grammar;
|
use leo_grammar::Grammar;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
fn to_core_ast(program_filepath: &Path) -> LeoCoreAst {
|
fn to_core_ast(program_filepath: &Path) -> LeoAst {
|
||||||
// Loads the Leo code as a string from the given file path.
|
// Loads the Leo code as a string from the given file path.
|
||||||
let program_string = Grammar::load_file(program_filepath).unwrap();
|
let program_string = Grammar::load_file(program_filepath).unwrap();
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ fn to_core_ast(program_filepath: &Path) -> LeoCoreAst {
|
|||||||
let ast = Grammar::new(&program_filepath, &program_string).unwrap();
|
let ast = Grammar::new(&program_filepath, &program_string).unwrap();
|
||||||
|
|
||||||
// Parses the pest ast and constructs a core ast.
|
// Parses the pest ast and constructs a core ast.
|
||||||
LeoCoreAst::new("leo_core_tree", &ast)
|
LeoAst::new("leo_core_tree", &ast)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -66,7 +66,7 @@ fn test_deserialize() {
|
|||||||
|
|
||||||
// Construct a core ast by deserializing a core ast JSON file.
|
// Construct a core ast by deserializing a core ast JSON file.
|
||||||
let serialized_typed_ast = include_str!("expected_core_ast.json");
|
let serialized_typed_ast = include_str!("expected_core_ast.json");
|
||||||
let core_ast = LeoCoreAst::from_json_string(serialized_typed_ast).unwrap();
|
let core_ast = LeoAst::from_json_string(serialized_typed_ast).unwrap();
|
||||||
|
|
||||||
assert_eq!(expected_core_ast, core_ast);
|
assert_eq!(expected_core_ast, core_ast);
|
||||||
}
|
}
|
||||||
@ -84,8 +84,8 @@ fn test_serialize_deserialize_serialize() {
|
|||||||
// Serializes the core ast into JSON format.
|
// Serializes the core ast into JSON format.
|
||||||
let serialized_core_ast = core_ast.to_json_string().unwrap();
|
let serialized_core_ast = core_ast.to_json_string().unwrap();
|
||||||
|
|
||||||
// Deserializes the serialized core ast into a LeoCoreAst.
|
// Deserializes the serialized core ast into a LeoAst.
|
||||||
let core_ast = LeoCoreAst::from_json_string(&serialized_core_ast).unwrap();
|
let core_ast = LeoAst::from_json_string(&serialized_core_ast).unwrap();
|
||||||
|
|
||||||
// Reserializes the core ast into JSON format.
|
// Reserializes the core ast into JSON format.
|
||||||
let reserialized_core_ast = core_ast.to_json_string().unwrap();
|
let reserialized_core_ast = core_ast.to_json_string().unwrap();
|
@ -17,8 +17,8 @@ include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
|
|||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies.leo-core-ast]
|
[dependencies.leo-ast]
|
||||||
path = "../core-ast"
|
path = "../ast"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
||||||
[dependencies.leo-core-packages]
|
[dependencies.leo-core-packages]
|
||||||
@ -124,4 +124,4 @@ default-features = false
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ ]
|
default = [ ]
|
||||||
ci_skip = [ "leo-grammar/ci_skip", "leo-core-ast/ci_skip" ]
|
ci_skip = [ "leo-grammar/ci_skip", "leo-ast/ci_skip" ]
|
||||||
|
@ -23,7 +23,7 @@ use crate::{
|
|||||||
OutputBytes,
|
OutputBytes,
|
||||||
OutputFile,
|
OutputFile,
|
||||||
};
|
};
|
||||||
use leo_core_ast::{Input, LeoCoreAst, MainInput, Program};
|
use leo_ast::{Input, LeoAst, MainInput, Program};
|
||||||
use leo_grammar::Grammar;
|
use leo_grammar::Grammar;
|
||||||
use leo_imports::ImportParser;
|
use leo_imports::ImportParser;
|
||||||
use leo_input::LeoInputParser;
|
use leo_input::LeoInputParser;
|
||||||
@ -184,7 +184,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Construct the core ast from the pest ast.
|
// Construct the core ast from the pest ast.
|
||||||
let core_ast = LeoCoreAst::new(&self.package_name, &pest_ast);
|
let core_ast = LeoAst::new(&self.package_name, &pest_ast);
|
||||||
|
|
||||||
// Store the main program file.
|
// Store the main program file.
|
||||||
self.program = core_ast.into_repr();
|
self.program = core_ast.into_repr();
|
||||||
@ -244,7 +244,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> Compiler<F, G> {
|
|||||||
let package_name = &self.package_name;
|
let package_name = &self.package_name;
|
||||||
|
|
||||||
// Construct the core ast from the pest ast.
|
// Construct the core ast from the pest ast.
|
||||||
let core_ast = LeoCoreAst::new(package_name, &ast);
|
let core_ast = LeoAst::new(package_name, &ast);
|
||||||
|
|
||||||
// Store the main program file.
|
// Store the main program file.
|
||||||
self.program = core_ast.into_repr();
|
self.program = core_ast.into_repr();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//! Enforces an assert equals statement in a compiled Leo program.
|
//! Enforces an assert equals statement in a compiled Leo program.
|
||||||
|
|
||||||
use crate::{errors::ConsoleError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
use crate::{errors::ConsoleError, program::ConstrainedProgram, value::ConstrainedValue, GroupType};
|
||||||
use leo_core_ast::{Expression, Span, Type};
|
use leo_ast::{Expression, Span, Type};
|
||||||
|
|
||||||
use snarkos_models::{
|
use snarkos_models::{
|
||||||
curves::{Field, PrimeField},
|
curves::{Field, PrimeField},
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//! Evaluates a macro in a compiled Leo program.
|
//! Evaluates a macro in a compiled Leo program.
|
||||||
|
|
||||||
use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType};
|
use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType};
|
||||||
use leo_core_ast::{ConsoleFunction, ConsoleFunctionCall};
|
use leo_ast::{ConsoleFunction, ConsoleFunctionCall};
|
||||||
|
|
||||||
use snarkos_models::{
|
use snarkos_models::{
|
||||||
curves::{Field, PrimeField},
|
curves::{Field, PrimeField},
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//! Evaluates a formatted string in a compiled Leo program.
|
//! Evaluates a formatted string in a compiled Leo program.
|
||||||
|
|
||||||
use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType};
|
use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType};
|
||||||
use leo_core_ast::FormattedString;
|
use leo_ast::FormattedString;
|
||||||
|
|
||||||
use snarkos_models::{
|
use snarkos_models::{
|
||||||
curves::{Field, PrimeField},
|
curves::{Field, PrimeField},
|
||||||
|
@ -25,7 +25,7 @@ use crate::{
|
|||||||
OutputBytes,
|
OutputBytes,
|
||||||
OutputFile,
|
OutputFile,
|
||||||
};
|
};
|
||||||
use leo_core_ast::{Input, Program};
|
use leo_ast::{Input, Program};
|
||||||
use leo_imports::ImportParser;
|
use leo_imports::ImportParser;
|
||||||
use leo_input::LeoInputParser;
|
use leo_input::LeoInputParser;
|
||||||
use leo_package::inputs::InputPairs;
|
use leo_package::inputs::InputPairs;
|
||||||
|
@ -21,7 +21,7 @@ use crate::{
|
|||||||
value::ConstrainedValue,
|
value::ConstrainedValue,
|
||||||
GroupType,
|
GroupType,
|
||||||
};
|
};
|
||||||
use leo_core_ast::Identifier;
|
use leo_ast::Identifier;
|
||||||
|
|
||||||
use snarkos_models::curves::{Field, PrimeField};
|
use snarkos_models::curves::{Field, PrimeField};
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ use crate::{
|
|||||||
value::ConstrainedValue,
|
value::ConstrainedValue,
|
||||||
GroupType,
|
GroupType,
|
||||||
};
|
};
|
||||||
use leo_core_ast::Program;
|
use leo_ast::Program;
|
||||||
use leo_imports::ImportParser;
|
use leo_imports::ImportParser;
|
||||||
|
|
||||||
use snarkos_models::curves::{Field, PrimeField};
|
use snarkos_models::curves::{Field, PrimeField};
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::errors::ExpressionError;
|
use crate::errors::ExpressionError;
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::errors::{AddressError, BooleanError, FieldError, FunctionError, GroupError, IntegerError, ValueError};
|
use crate::errors::{AddressError, BooleanError, FieldError, FunctionError, GroupError, IntegerError, ValueError};
|
||||||
use leo_core_ast::{Error as FormattedError, Identifier, Span};
|
use leo_ast::{Error as FormattedError, Identifier, Span};
|
||||||
use leo_core_packages::LeoCorePackageError;
|
use leo_core_packages::LeoCorePackageError;
|
||||||
|
|
||||||
use snarkos_errors::gadgets::SynthesisError;
|
use snarkos_errors::gadgets::SynthesisError;
|
||||||
|
@ -25,7 +25,7 @@ use crate::errors::{
|
|||||||
StatementError,
|
StatementError,
|
||||||
ValueError,
|
ValueError,
|
||||||
};
|
};
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Identifier, ImportSymbol, Span};
|
use leo_ast::{Error as FormattedError, Identifier, ImportSymbol, Span};
|
||||||
use leo_core_packages::LeoCorePackageError;
|
use leo_core_packages::LeoCorePackageError;
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::errors::{AddressError, BooleanError, ConsoleError, ExpressionError, IntegerError, ValueError};
|
use crate::errors::{AddressError, BooleanError, ConsoleError, ExpressionError, IntegerError, ValueError};
|
||||||
use leo_core_ast::{Error as FormattedError, Span, Type};
|
use leo_ast::{Error as FormattedError, Span, Type};
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use snarkos_errors::{gadgets::SynthesisError, objects::account::AccountError};
|
use snarkos_errors::{gadgets::SynthesisError, objects::account::AccountError};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use snarkos_errors::gadgets::SynthesisError;
|
use snarkos_errors::gadgets::SynthesisError;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use snarkos_errors::gadgets::SynthesisError;
|
use snarkos_errors::gadgets::SynthesisError;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use leo_core_ast::{Error as FormattedError, Span};
|
use leo_ast::{Error as FormattedError, Span};
|
||||||
|
|
||||||
use snarkos_errors::gadgets::SynthesisError;
|
use snarkos_errors::gadgets::SynthesisError;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user