mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
Merge pull request #111 from edsrzf/shorthand-ternary-precedence
This commit is contained in:
commit
54d0901a84
@ -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