parser: support clone expressions

This commit is contained in:
Ryan Chandler 2022-07-28 20:05:04 +01:00
parent ad4f005511
commit 67a26ae78f
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
3 changed files with 11 additions and 0 deletions

View File

@ -695,6 +695,7 @@ fn identifier_to_keyword(ident: &str) -> Option<TokenKind> {
"as" => TokenKind::As,
"break" => TokenKind::Break,
"class" => TokenKind::Class,
"clone" => TokenKind::Clone,
"continue" => TokenKind::Continue,
"const" => TokenKind::Const,
"declare" => TokenKind::Declare,

View File

@ -284,6 +284,7 @@ pub enum Expression {
MagicConst(MagicConst),
Ternary(Box<Self>, Box<Self>, Box<Self>),
Coalesce(Box<Self>, Box<Self>),
Clone(Box<Self>)
}
#[derive(Debug, Eq, PartialEq, Clone, Serialize)]

View File

@ -718,6 +718,15 @@ impl Parser {
}
let mut lhs = match &self.current.kind {
TokenKind::Clone => {
self.next();
let target = self.expression(0)?;
dbg!(&self.current.kind);
Expression::Clone(Box::new(target))
},
TokenKind::Variable(v) => {
let e = Expression::Variable(v.to_string());
self.next();