From a0ab1524e6bf4979045c2e382691774b2f75918b Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Thu, 11 Jul 2024 09:31:11 -0700 Subject: [PATCH 1/2] Fix some doc. --- compiler/parser/src/parser/context.rs | 2 +- compiler/parser/src/parser/file.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index da9ade6085..3e2db39f7d 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -201,7 +201,7 @@ impl<'a, N: Network> ParserContext<'a, N> { } /// Parses a list of `T`s using `inner` - /// The opening and closing delimiters are `bra` and `ket`, + /// The opening and closing delimiters are specified in `delimiter`, /// and elements in the list are optionally separated by `sep`. /// When `(list, true)` is returned, `sep` was a terminator. pub(super) fn parse_list( diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index afc79846a9..401f968d6d 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -296,7 +296,7 @@ impl ParserContext<'_, N> { } } - /// Returns a [`Input`] AST node if the next tokens represent a function output. + /// Returns an [`Input`] AST node if the next tokens represent a function input. fn parse_input(&mut self) -> Result { let mode = self.parse_mode()?; let name = self.expect_identifier()?; @@ -307,7 +307,7 @@ impl ParserContext<'_, N> { Ok(functions::Input { identifier: name, mode, type_, span: name.span, id: self.node_builder.next_id() }) } - /// Returns a [`Output`] AST node if the next tokens represent a function output. + /// Returns an [`Output`] AST node if the next tokens represent a function output. fn parse_output(&mut self) -> Result { let mode = self.parse_mode()?; let (type_, span) = self.parse_type()?; @@ -377,7 +377,8 @@ impl ParserContext<'_, N> { } }; - // Parse the function body. Allow empty blocks. `fn foo(a:u8);` + // Parse the function body, which must be a block, + // but we also allow no body and a semicolon instead (e.g. `fn foo(a:u8);`). let (_has_empty_block, block) = match &self.token.token { Token::LeftCurly => (false, self.parse_block()?), Token::Semicolon => { From f72e4c10b501e7f4dfe895255b2d408fe1bfce6b Mon Sep 17 00:00:00 2001 From: Alessandro Coglio Date: Thu, 11 Jul 2024 10:00:10 -0700 Subject: [PATCH 2/2] Flag a TODO as discussed on Slack. --- compiler/parser/src/parser/file.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 401f968d6d..1a6e4c64d9 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -383,6 +383,7 @@ impl ParserContext<'_, N> { Token::LeftCurly => (false, self.parse_block()?), Token::Semicolon => { let semicolon = self.expect(&Token::Semicolon)?; + // TODO: make a distinction between empty block and no block (i.e. semicolon) (true, Block { statements: Vec::new(), span: semicolon, id: self.node_builder.next_id() }) } _ => self.unexpected("block or semicolon")?,