mirror of
https://github.com/danog/parser.git
synced 2025-01-22 13:01:32 +01:00
parent
5eca385a9a
commit
d602902d7b
@ -320,6 +320,7 @@ pub enum InfixOp {
|
||||
NotIdentical,
|
||||
And,
|
||||
Or,
|
||||
Assign,
|
||||
AddAssign,
|
||||
}
|
||||
|
||||
@ -341,6 +342,7 @@ impl From<TokenKind> for InfixOp {
|
||||
TokenKind::BangDoubleEquals => Self::NotIdentical,
|
||||
TokenKind::BooleanAnd => Self::And,
|
||||
TokenKind::BooleanOr => Self::Or,
|
||||
TokenKind::Equals => Self::Assign,
|
||||
TokenKind::PlusEquals => Self::AddAssign,
|
||||
_ => unreachable!()
|
||||
}
|
||||
|
@ -1202,10 +1202,6 @@ fn prefix(op: &TokenKind, rhs: Expression) -> Expression {
|
||||
}
|
||||
|
||||
fn infix(lhs: Expression, op: TokenKind, rhs: Expression) -> Expression {
|
||||
if op == TokenKind::Equals {
|
||||
return Expression::Assign(Box::new(lhs), Box::new(rhs));
|
||||
}
|
||||
|
||||
Expression::Infix(Box::new(lhs), op.into(), Box::new(rhs))
|
||||
}
|
||||
|
||||
@ -1350,11 +1346,12 @@ mod tests {
|
||||
#[test]
|
||||
fn array_index_assign() {
|
||||
assert_ast("<?php $foo['bar'] = 'baz';", &[
|
||||
expr!(Expression::Assign(
|
||||
expr!(Expression::Infix(
|
||||
Box::new(Expression::ArrayIndex(
|
||||
Box::new(Expression::Variable("foo".into())),
|
||||
Some(Box::new(Expression::ConstantString("bar".into())))
|
||||
)),
|
||||
InfixOp::Assign,
|
||||
Box::new(Expression::ConstantString("baz".into()))
|
||||
))
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user