diff --git a/ast/src/input/parameter.rs b/ast/src/input/_parameter.rs similarity index 100% rename from ast/src/input/parameter.rs rename to ast/src/input/_parameter.rs diff --git a/ast/src/input/mod.rs b/ast/src/input/mod.rs index fc11a72030..faa9c04dc4 100644 --- a/ast/src/input/mod.rs +++ b/ast/src/input/mod.rs @@ -23,8 +23,8 @@ pub use input::*; pub mod input_value; pub use input_value::*; -pub mod parameter; -pub use parameter::*; +// pub mod parameter; +// pub use parameter::*; pub mod program_input; pub use program_input::*; @@ -39,6 +39,6 @@ use indexmap::IndexMap; use leo_errors::{InputError, LeoError, Result}; use leo_span::{sym, Span, Symbol}; use serde::{Deserialize, Serialize}; -use std::fmt; +// use std::fmt; -type Definitions = IndexMap; +type Definitions = IndexMap; diff --git a/ast/src/input/program_input.rs b/ast/src/input/program_input.rs index ba2ab8cf77..96ff686758 100644 --- a/ast/src/input/program_input.rs +++ b/ast/src/input/program_input.rs @@ -48,7 +48,7 @@ impl TryFrom for ProgramInput { for definition in section.definitions { target.insert( - Parameter::from(definition.clone()), + definition.name.name, InputValue::try_from((definition.type_, definition.value))?, ); } diff --git a/ast/src/input/program_state.rs b/ast/src/input/program_state.rs index 7ba88daef1..7dbfc5caf8 100644 --- a/ast/src/input/program_state.rs +++ b/ast/src/input/program_state.rs @@ -20,44 +20,31 @@ use super::*; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct ProgramState { pub state: Definitions, - pub record: Definitions, - pub state_leaf: Definitions, } impl TryFrom for ProgramState { type Error = LeoError; fn try_from(input: ParsedInputFile) -> Result { let mut state = IndexMap::new(); - let mut record = IndexMap::new(); - let mut state_leaf = IndexMap::new(); for section in input.sections { - let target = match section.name { - sym::state => &mut state, - sym::record => &mut record, - sym::state_leaf => &mut state_leaf, - _ => { - return Err(InputError::unexpected_section( - &["state", "record", "state_leaf"], - section.name, - §ion.span, - ) - .into()) + if matches!(section.name, sym::state | sym::record | sym::state_leaf) { + for definition in section.definitions { + state.insert( + definition.name.name, + InputValue::try_from((definition.type_, definition.value))?, + ); } - }; - - for definition in section.definitions { - target.insert( - Parameter::from(definition.clone()), - InputValue::try_from((definition.type_, definition.value))?, - ); + } else { + return Err(InputError::unexpected_section( + &["state", "record", "state_leaf"], + section.name, + §ion.span, + ) + .into()); } } - Ok(ProgramState { - state, - record, - state_leaf, - }) + Ok(ProgramState { state }) } } diff --git a/errors/src/input/input_errors.rs b/errors/src/input/input_errors.rs index 2eb8d9e1fc..a218fbf380 100644 --- a/errors/src/input/input_errors.rs +++ b/errors/src/input/input_errors.rs @@ -15,10 +15,7 @@ // along with the Leo library. If not, see . use crate::create_errors; -use std::{ - error::Error as ErrorArg, - fmt::{Debug, Display}, -}; +use std::fmt::{Debug, Display}; create_errors!( /// InputError enum that represents all the errors for the inputs part of `leo-ast` crate.