From af6d3423a020555ad785e5671c4d542532071939 Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Wed, 27 Sep 2023 14:19:27 -0700 Subject: [PATCH] [Aleo ins parser] Minor code and doc fixes. This is for futures. Update some doc comments. The code fix is for parsing whitespace just before commas of future arguments. The current code allows comments and new lines there, which I don't think we want (not wrong per se, but anomalous, inconsistent with other parts of the syntax). So the fix restricts that to just whitespace (no comments) without new lines. We still allow comments and new lines after the comma, consistently with other parts of the syntax. --- console/program/src/data/future/parse.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/console/program/src/data/future/parse.rs b/console/program/src/data/future/parse.rs index 616ae22c14..c54356afed 100644 --- a/console/program/src/data/future/parse.rs +++ b/console/program/src/data/future/parse.rs @@ -28,7 +28,7 @@ impl Parser for Future { let (string, _) = Sanitizer::parse(string)?; // Parse the members. let (string, arguments) = separated_list0( - pair(pair(Sanitizer::parse, tag(",")), Sanitizer::parse), + pair(pair(Sanitizer::parse_whitespaces, tag(",")), Sanitizer::parse), alt((map(Future::parse, Argument::Future), map(Plaintext::parse, Argument::Plaintext))), )(string)?; // Parse the whitespace and comments from the string. @@ -103,7 +103,7 @@ impl Parser for Future { impl FromStr for Future { type Err = Error; - /// Returns a plaintext from a string literal. + /// Returns a future from a string literal. fn from_str(string: &str) -> Result { match Self::parse(string) { Ok((remainder, object)) => { @@ -118,21 +118,21 @@ impl FromStr for Future { } impl Debug for Future { - /// Prints the plaintext as a string. + /// Prints the future as a string. fn fmt(&self, f: &mut Formatter) -> fmt::Result { Display::fmt(self, f) } } impl Display for Future { - /// Prints the plaintext as a string. + /// Prints the future as a string. fn fmt(&self, f: &mut Formatter) -> fmt::Result { self.fmt_internal(f, 0) } } impl Future { - /// Prints the plaintext with the given indentation depth. + /// Prints the future with the given indentation depth. fn fmt_internal(&self, f: &mut Formatter, depth: usize) -> fmt::Result { /// The number of spaces to indent. const INDENT: usize = 2;