2020-07-29 11:12:17 +03:00
|
|
|
//! 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;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::circuits::*;
|
2020-06-08 05:19:38 +03:00
|
|
|
|
2020-06-08 05:47:35 +03:00
|
|
|
pub mod common;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::common::*;
|
2020-06-08 05:47:35 +03:00
|
|
|
|
2020-06-08 04:22:59 +03:00
|
|
|
pub mod errors;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::errors::*;
|
2020-06-08 04:22:59 +03:00
|
|
|
|
2020-06-08 05:19:38 +03:00
|
|
|
pub mod expression;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::expression::*;
|
2020-06-08 05:19:38 +03:00
|
|
|
|
2020-06-08 06:35:50 +03:00
|
|
|
pub mod functions;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::functions::*;
|
2020-06-08 06:35:50 +03:00
|
|
|
|
2020-06-08 06:50:37 +03:00
|
|
|
pub mod imports;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::imports::*;
|
2020-06-08 06:50:37 +03:00
|
|
|
|
2020-06-10 02:36:15 +03:00
|
|
|
pub mod inputs;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::inputs::*;
|
2020-06-08 04:22:59 +03:00
|
|
|
|
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;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::program::*;
|
2020-06-08 06:57:22 +03:00
|
|
|
|
2020-06-08 06:24:27 +03:00
|
|
|
pub mod statements;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::statements::*;
|
2020-06-08 06:24:27 +03:00
|
|
|
|
2020-06-08 05:47:35 +03:00
|
|
|
pub mod types;
|
2020-07-02 07:05:57 +03:00
|
|
|
pub use self::types::*;
|
2020-07-29 11:12:17 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|