mirror of
https://github.com/danog/parser.git
synced 2024-11-26 11:54:59 +01:00
parser: treat ? : same as ?: combined
This commit is contained in:
parent
4076aeea85
commit
7e66e812d9
@ -93,12 +93,17 @@ fn for_precedence(state: &mut State, precedence: Precedence) -> ParseResult<Expr
|
|||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
TokenKind::Question => {
|
TokenKind::Question => {
|
||||||
let then = lowest_precedence(state)?;
|
let then = if state.current.kind == TokenKind::Colon {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(Box::new(lowest_precedence(state)?))
|
||||||
|
};
|
||||||
|
|
||||||
utils::skip_colon(state)?;
|
utils::skip_colon(state)?;
|
||||||
let otherwise = for_precedence(state, rpred)?;
|
let otherwise = for_precedence(state, rpred)?;
|
||||||
left = Expression::Ternary {
|
left = Expression::Ternary {
|
||||||
condition: Box::new(left),
|
condition: Box::new(left),
|
||||||
then: Some(Box::new(then)),
|
then,
|
||||||
r#else: Box::new(otherwise),
|
r#else: Box::new(otherwise),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user