mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
pulling parser changes from prev branch
This commit is contained in:
parent
24e5c4d69e
commit
9951627c8c
@ -604,7 +604,9 @@ impl ParserContext {
|
||||
}
|
||||
let first = self.parse_spread_or_expression()?;
|
||||
if self.eat(Token::Semicolon).is_some() {
|
||||
let dimensions = self.parse_array_dimensions()?;
|
||||
let dimensions = self
|
||||
.parse_array_dimensions()?
|
||||
.ok_or_else(|| ParserError::unable_to_parse_array_dimensions(span))?;
|
||||
let end = self.expect(Token::RightSquare)?;
|
||||
let first = match first {
|
||||
SpreadOrExpression::Spread(first) => {
|
||||
|
@ -58,9 +58,11 @@ impl ParserContext {
|
||||
///
|
||||
/// Returns an [`ArrayDimensions`] AST node if the next tokens represent dimensions for an array type.
|
||||
///
|
||||
pub fn parse_array_dimensions(&mut self) -> Result<ArrayDimensions> {
|
||||
pub fn parse_array_dimensions(&mut self) -> Result<Option<ArrayDimensions>> {
|
||||
Ok(if let Some((int, _)) = self.eat_int() {
|
||||
ArrayDimensions(vec![int])
|
||||
Some(ArrayDimensions(vec![int]))
|
||||
} else if self.eat(Token::Underscore).is_some() {
|
||||
None
|
||||
} else {
|
||||
self.expect(Token::LeftParen)?;
|
||||
let mut dimensions = Vec::new();
|
||||
@ -76,7 +78,7 @@ impl ParserContext {
|
||||
}
|
||||
}
|
||||
self.expect(Token::RightParen)?;
|
||||
ArrayDimensions(dimensions)
|
||||
Some(ArrayDimensions(dimensions))
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user