From 0e00cbc4229403fb85945893ce7f6832e2696f9f Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 10 Aug 2020 15:51:39 -0700 Subject: [PATCH] clean up comments --- ast/src/leo.pest | 23 +++++------- ast/src/statements/mod.rs | 3 -- .../multiple_assignment_statement.rs | 36 ------------------- 3 files changed, 8 insertions(+), 54 deletions(-) delete mode 100644 ast/src/statements/multiple_assignment_statement.rs diff --git a/ast/src/leo.pest b/ast/src/leo.pest index 5f109eab60..260f83f87d 100644 --- a/ast/src/leo.pest +++ b/ast/src/leo.pest @@ -69,16 +69,10 @@ static_ = { "static " } // Declared in common/variable_name.rs variable_name = {mutable? ~ identifier} -variable_name_list = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} - -// Declared in - -// Declared in common/variable.rs -// variable = { mutable? ~ identifier ~ (":" ~ type_)? } -// variable_list = _{ variable ~ ("," ~ variable)* } +variable_name_tuple = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} // Declared in common/variables.rs -variables = { ( variable_name_list | variable_name ) ~ (":" ~ ( type_list | type_ ))? } +variables = { ( variable_name_tuple | variable_name ) ~ (":" ~ ( type_tuple | type_ ))? } // Declared in common/declare.rs declare = { let_ | const_ } @@ -203,7 +197,7 @@ type_circuit = { identifier } // Declared in types/array_type.rs type_array = { type_data ~ ("[" ~ number_positive ~ "]")+ } -type_list = _{ "(" ~ type_ ~ ("," ~ type_)+ ~ ")" } +type_tuple = _{ "(" ~ type_ ~ ("," ~ type_)+ ~ ")" } /// Values @@ -264,7 +258,7 @@ access_array = !{ "[" ~ range_or_expression ~ "]" } access_assignee = { access_array | access_member } // Declared in access/call_access.rs -access_call = !{ expression_list } +access_call = !{ expression_tuple } // Declared in access/member_access.rs access_member = ${ "." ~ identifier } @@ -310,7 +304,7 @@ expression_term = { // Declared in expressions/expression.rs expression = { expression_term ~ (operation_binary ~ expression_term)* } -expression_list = _{ "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" } +expression_tuple = _{ "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" } // Declared in expressions/array_initializer_expression.rs expression_array_initializer = { "[" ~ spread_or_expression ~ ";" ~ number_positive ~ "]" } @@ -336,7 +330,6 @@ statement = { (statement_return | statement_conditional | statement_for -// | statement_multiple_assignment | statement_macro | statement_definition | statement_assign @@ -358,7 +351,7 @@ statement_conditional = {"if " ~ (expression | "(" ~ expression ~ ")") ~ "{" ~ N conditional_nested_or_end_statement = { statement_conditional | "{" ~ NEWLINE* ~ statement+ ~ "}"} // Declared in statements/definition_statement.rs -statement_definition = { declare ~ variables ~ "=" ~ (expression_list | expression) ~ LINE_END} +statement_definition = { declare ~ variables ~ "=" ~ (expression_tuple | expression) ~ LINE_END} // Declared in statements/expression_statement.rs statement_expression = { expression ~ LINE_END } @@ -375,7 +368,7 @@ statement_return = { "return " ~ return_} test_function = { "test " ~ function } // Declared in functions/function.rs -function = { "function " ~ identifier ~ input_list ~ ("->" ~ (type_list| type_))? ~ "{" ~ NEWLINE* ~ statement* ~ NEWLINE* ~ "}" ~ NEWLINE* } +function = { "function " ~ identifier ~ input_tuple ~ ("->" ~ (type_tuple| type_))? ~ "{" ~ NEWLINE* ~ statement* ~ NEWLINE* ~ "}" ~ NEWLINE* } // Declared in functions/input/function_input.rs function_input = { mutable? ~ identifier ~ ":" ~ type_ } @@ -388,7 +381,7 @@ input = { function_input | input_keyword } -input_list = _{ "(" ~(input ~ ("," ~ NEWLINE* ~ input)*)? ~ ")"} +input_tuple = _{ "(" ~(input ~ ("," ~ NEWLINE* ~ input)*)? ~ ")"} /// Imports diff --git a/ast/src/statements/mod.rs b/ast/src/statements/mod.rs index f2bc27cf66..50202579e5 100644 --- a/ast/src/statements/mod.rs +++ b/ast/src/statements/mod.rs @@ -19,9 +19,6 @@ pub use expression_statement::*; pub mod for_statement; pub use for_statement::*; -// pub mod multiple_assignment_statement; -// pub use multiple_assignment_statement::*; - pub mod return_statement; pub use return_statement::*; diff --git a/ast/src/statements/multiple_assignment_statement.rs b/ast/src/statements/multiple_assignment_statement.rs deleted file mode 100644 index 17a6dd99ee..0000000000 --- a/ast/src/statements/multiple_assignment_statement.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::{ - ast::Rule, - common::{Declare, Identifier, LineEnd, Variable}, - expressions::Expression, - SpanDef, -}; - -use pest::Span; -use pest_ast::FromPest; -use serde::Serialize; -use std::fmt; - -#[derive(Clone, Debug, FromPest, PartialEq, Serialize)] -#[pest_ast(rule(Rule::statement_multiple_assignment))] -pub struct MultipleAssignmentStatement<'ast> { - pub declare: Declare, - pub variables: Vec>, - pub function_name: Identifier<'ast>, - pub arguments: Vec>, - pub line_end: LineEnd, - #[pest_ast(outer())] - #[serde(with = "SpanDef")] - pub span: Span<'ast>, -} - -impl<'ast> fmt::Display for MultipleAssignmentStatement<'ast> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for (i, id) in self.variables.iter().enumerate() { - write!(f, "{}", id)?; - if i < self.variables.len() - 1 { - write!(f, ", ")?; - } - } - write!(f, " = {}", self.function_name) - } -}