rename circuit_field -> circuit_variable in ast

This commit is contained in:
collin 2020-09-02 14:07:19 -07:00
parent 3b737b2a34
commit 16f3cbd3dd
7 changed files with 21 additions and 21 deletions

View File

@ -16,7 +16,7 @@
use crate::{
ast::Rule,
circuits::{CircuitFieldDefinition, CircuitFunction},
circuits::{CircuitFunction, CircuitVariableDefinition},
};
use pest_ast::FromPest;
@ -25,6 +25,6 @@ use serde::Serialize;
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
#[pest_ast(rule(Rule::circuit_member))]
pub enum CircuitMember<'ast> {
CircuitFieldDefinition(CircuitFieldDefinition<'ast>),
CircuitVariableDefinition(CircuitVariableDefinition<'ast>),
CircuitFunction(CircuitFunction<'ast>),
}

View File

@ -21,8 +21,8 @@ use pest_ast::FromPest;
use serde::Serialize;
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
#[pest_ast(rule(Rule::circuit_field))]
pub struct CircuitField<'ast> {
#[pest_ast(rule(Rule::circuit_variable))]
pub struct CircuitVariable<'ast> {
pub identifier: Identifier<'ast>,
pub expression: Expression<'ast>,
#[pest_ast(outer())]

View File

@ -21,8 +21,8 @@ use pest_ast::FromPest;
use serde::Serialize;
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
#[pest_ast(rule(Rule::circuit_field_definition))]
pub struct CircuitFieldDefinition<'ast> {
#[pest_ast(rule(Rule::circuit_variable_definition))]
pub struct CircuitVariableDefinition<'ast> {
pub identifier: Identifier<'ast>,
pub _type: Type<'ast>,
#[pest_ast(outer())]

View File

@ -17,11 +17,11 @@
pub mod circuit;
pub use circuit::*;
pub mod circuit_field;
pub use circuit_field::*;
pub mod circuit_variable;
pub use circuit_variable::*;
pub mod circuit_field_definition;
pub use circuit_field_definition::*;
pub mod circuit_variable_definition;
pub use circuit_variable_definition::*;
pub mod circuit_function;
pub use circuit_function::*;

View File

@ -14,7 +14,7 @@
// 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/>.
use crate::{ast::Rule, circuits::CircuitField, common::Identifier, SpanDef};
use crate::{ast::Rule, circuits::CircuitVariable, common::Identifier, SpanDef};
use pest::Span;
use pest_ast::FromPest;
@ -24,7 +24,7 @@ use serde::Serialize;
#[pest_ast(rule(Rule::expression_circuit_inline))]
pub struct CircuitInlineExpression<'ast> {
pub identifier: Identifier<'ast>,
pub members: Vec<CircuitField<'ast>>,
pub members: Vec<CircuitVariable<'ast>>,
#[pest_ast(outer())]
#[serde(with = "SpanDef")]
pub span: Span<'ast>,

View File

@ -285,17 +285,17 @@ access_static_member = ${ "::" ~ identifier }
// Declared in circuits/circuit_definition.rs
circuit = { "circuit " ~ identifier ~ "{" ~ NEWLINE* ~ circuit_member* ~ NEWLINE* ~ "}" ~ NEWLINE* }
// Declared in circuits/circuit_field.rs
circuit_field = { identifier ~ ":" ~ expression }
// Declared in circuits/circuit_variable.rs
circuit_variable = { identifier ~ ":" ~ expression }
// Declared in circuits/circuit_field_definition.rs
circuit_field_definition = { identifier ~ ":" ~ type_ ~ ","?}
// Declared in circuits/circuit_variable_definition.rs
circuit_variable_definition = { identifier ~ ":" ~ type_ ~ ","?}
// Declared in circuits/circuit_function.rs
circuit_function = { static_? ~ function }
// Declared in circuits/circuit_member.rs
circuit_member = { circuit_function | circuit_field_definition ~ NEWLINE*}
circuit_member = { circuit_function | circuit_variable_definition ~ NEWLINE*}
/// Conditionals
@ -331,8 +331,8 @@ expression_array_inline = { "[" ~ NEWLINE* ~ inline_array_inner ~ NEWLINE* ~ "]"
inline_array_inner = _{(spread_or_expression ~ ("," ~ NEWLINE* ~ spread_or_expression)*)?}
// Declared in expressions/circuit_inline_expression.rs
expression_circuit_inline = { identifier ~ "{" ~ NEWLINE* ~ circuit_field_list ~ NEWLINE* ~ "}" }
circuit_field_list = _{ (circuit_field ~ ("," ~ NEWLINE* ~ circuit_field)*)? ~ ","? }
expression_circuit_inline = { identifier ~ "{" ~ NEWLINE* ~ circuit_variable_list ~ NEWLINE* ~ "}" }
circuit_variable_list = _{ (circuit_variable ~ ("," ~ NEWLINE* ~ circuit_variable)*)? ~ ","? }
// Declared in expressions/unary_expression.rs
expression_unary = { operation_unary ~ expression_term }

View File

@ -16,9 +16,9 @@
use crate::{Function, Identifier, Type};
use leo_ast::circuits::{
CircuitFieldDefinition as AstCircuitFieldDefinition,
CircuitFunction as AstCircuitFunction,
CircuitMember as AstCircuitMember,
CircuitVariableDefinition as AstCircuitFieldDefinition,
};
use serde::{Deserialize, Serialize};
@ -51,7 +51,7 @@ impl<'ast> From<AstCircuitFunction<'ast>> for CircuitMember {
impl<'ast> From<AstCircuitMember<'ast>> for CircuitMember {
fn from(object: AstCircuitMember<'ast>) -> Self {
match object {
AstCircuitMember::CircuitFieldDefinition(circuit_value) => CircuitMember::from(circuit_value),
AstCircuitMember::CircuitVariableDefinition(circuit_value) => CircuitMember::from(circuit_value),
AstCircuitMember::CircuitFunction(circuit_function) => CircuitMember::from(circuit_function),
}
}