aaa more ambiguity fixed

This commit is contained in:
TriMill 2022-09-22 22:34:23 -04:00
parent 99f2ce851c
commit 3744062c71
2 changed files with 3 additions and 2 deletions

View file

@ -219,6 +219,7 @@ impl Lexer {
},
_ => self.add_token(TokenType::Pipe, "|"),
},
'~' => self.add_token(TokenType::Tilde, "~"),
',' => self.add_token(TokenType::Comma, ","),
';' => self.add_token(TokenType::Semicolon, ";"),
':' => self.add_token(TokenType::Colon, ":"),

View file

@ -449,7 +449,7 @@ impl Parser {
match self.peek().ty {
TokenType::LParen => expr = self.fncall_inner(expr)?,
TokenType::LBrack => expr = self.arrindex_inner(expr)?,
TokenType::Colon => expr = self.structinit_inner(expr)?,
TokenType::Tilde => expr = self.structinit_inner(expr)?,
_ => return Ok(expr)
}
}
@ -478,7 +478,7 @@ impl Parser {
fn structinit_inner(&mut self, expr: Expr) -> Result<Expr, ParserError> {
let colon = self.next();
if !self.expect(TokenType::LBrace).0 {
return Err(self.mk_error("Expected left brace in struct initialization"))
return Err(self.mk_error("Expected tilde in struct initialization"))
}
let args = self.commalist(TokenType::RBrace, Self::assignment)?;
Ok(Expr::StructInit { ty: Box::new(expr), args, pos: colon.pos })