mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-11 15:05:33 +03:00
commit
ecd1c7fe0e
@ -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<T>(
|
||||
|
@ -296,7 +296,7 @@ impl<N: Network> 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<functions::Input> {
|
||||
let mode = self.parse_mode()?;
|
||||
let name = self.expect_identifier()?;
|
||||
@ -307,7 +307,7 @@ impl<N: Network> 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<Output> {
|
||||
let mode = self.parse_mode()?;
|
||||
let (type_, span) = self.parse_type()?;
|
||||
@ -377,11 +377,13 @@ impl<N: Network> 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 => {
|
||||
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")?,
|
||||
|
Loading…
Reference in New Issue
Block a user