mirror of
https://github.com/danog/parser.git
synced 2024-11-26 20:04:57 +01:00
Add precedence for shorthand ternary operator
This commit is contained in:
parent
723244eca0
commit
46abeec2b8
@ -2783,6 +2783,19 @@ mod tests {
|
||||
r#else: Box::new(Expression::Int { i: 5 }),
|
||||
})],
|
||||
);
|
||||
|
||||
assert_ast(
|
||||
"<?php 1 ?: 2 ?: 3;",
|
||||
&[expr!(Expression::Ternary {
|
||||
condition: Box::new(Expression::Int { i: 1 }),
|
||||
then: None,
|
||||
r#else: Box::new(Expression::Ternary {
|
||||
condition: Box::new(Expression::Int { i: 2 }),
|
||||
then: None,
|
||||
r#else: Box::new(Expression::Int { i: 3 })
|
||||
}),
|
||||
})],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -64,7 +64,7 @@ impl Precedence {
|
||||
BooleanAnd => Self::And,
|
||||
BooleanOr => Self::Or,
|
||||
Coalesce => Self::NullCoalesce,
|
||||
Question => Self::Ternary,
|
||||
Question | QuestionColon => Self::Ternary,
|
||||
Equals | PlusEquals | MinusEquals | AsteriskEqual | PowEquals | SlashEquals
|
||||
| DotEquals | AndEqual | CoalesceEqual | PercentEquals | AmpersandEquals
|
||||
| PipeEquals | CaretEquals | LeftShiftEquals | RightShiftEquals => Self::Assignment,
|
||||
|
Loading…
Reference in New Issue
Block a user