leo/typed/src/lib.rs

55 lines
1.1 KiB
Rust
Raw Normal View History

//! A typed syntax tree is represented as a `Program` and consists of import, circuit, and function definitions.
//! Each defined type consists of typed statements and expressions.
2020-06-08 06:45:19 +03:00
pub mod circuits;
pub use self::circuits::*;
2020-06-08 05:47:35 +03:00
pub mod common;
pub use self::common::*;
2020-06-08 05:47:35 +03:00
pub mod errors;
pub use self::errors::*;
pub mod expression;
pub use self::expression::*;
2020-06-08 06:35:50 +03:00
pub mod functions;
pub use self::functions::*;
2020-06-08 06:35:50 +03:00
2020-06-08 06:50:37 +03:00
pub mod imports;
pub use self::imports::*;
2020-06-08 06:50:37 +03:00
2020-06-10 02:36:15 +03:00
pub mod inputs;
pub use self::inputs::*;
2020-07-09 11:39:13 +03:00
pub mod macros;
pub use self::macros::*;
2020-06-08 06:57:22 +03:00
pub mod program;
pub use self::program::*;
2020-06-08 06:57:22 +03:00
2020-06-08 06:24:27 +03:00
pub mod statements;
pub use self::statements::*;
2020-06-08 06:24:27 +03:00
2020-06-08 05:47:35 +03:00
pub mod types;
pub use self::types::*;
use leo_ast::LeoAst;
pub struct LeoTypedAst {
typed_ast: Program,
}
impl LeoTypedAst {
/// Creates a new typed syntax tree from a given program name and abstract syntax tree.
pub fn new<'ast>(program_name: &str, ast: &LeoAst<'ast>) -> Self {
Self {
typed_ast: Program::from(program_name, ast.as_repr()),
}
}
pub fn into_repr(self) -> Program {
self.typed_ast
}
}