mirror of
https://github.com/danog/parser.git
synced 2024-12-02 09:27:50 +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 }),
|
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]
|
#[test]
|
||||||
|
@ -64,7 +64,7 @@ impl Precedence {
|
|||||||
BooleanAnd => Self::And,
|
BooleanAnd => Self::And,
|
||||||
BooleanOr => Self::Or,
|
BooleanOr => Self::Or,
|
||||||
Coalesce => Self::NullCoalesce,
|
Coalesce => Self::NullCoalesce,
|
||||||
Question => Self::Ternary,
|
Question | QuestionColon => Self::Ternary,
|
||||||
Equals | PlusEquals | MinusEquals | AsteriskEqual | PowEquals | SlashEquals
|
Equals | PlusEquals | MinusEquals | AsteriskEqual | PowEquals | SlashEquals
|
||||||
| DotEquals | AndEqual | CoalesceEqual | PercentEquals | AmpersandEquals
|
| DotEquals | AndEqual | CoalesceEqual | PercentEquals | AmpersandEquals
|
||||||
| PipeEquals | CaretEquals | LeftShiftEquals | RightShiftEquals => Self::Assignment,
|
| PipeEquals | CaretEquals | LeftShiftEquals | RightShiftEquals => Self::Assignment,
|
||||||
|
Loading…
Reference in New Issue
Block a user