mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
parser: support clone expressions
This commit is contained in:
parent
ad4f005511
commit
67a26ae78f
@ -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,
|
||||
|
@ -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)]
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user