mirror of
https://github.com/danog/parser.git
synced 2025-01-22 21:11:55 +01:00
parser: support nullsafe property fetch
This commit is contained in:
parent
489cb0e884
commit
874e59d270
@ -380,6 +380,10 @@ pub enum Expression {
|
||||
target: Box<Self>,
|
||||
property: Box<Self>,
|
||||
},
|
||||
NullsafePropertyFetch {
|
||||
target: Box<Self>,
|
||||
property: Box<Self>,
|
||||
},
|
||||
StaticPropertyFetch {
|
||||
target: Box<Self>,
|
||||
property: Box<Self>
|
||||
|
@ -1493,7 +1493,7 @@ impl Parser {
|
||||
},
|
||||
}
|
||||
},
|
||||
TokenKind::Arrow => {
|
||||
TokenKind::Arrow | TokenKind::NullsafeArrow => {
|
||||
let property = match self.current.kind {
|
||||
TokenKind::LeftBrace => {
|
||||
self.lbrace()?;
|
||||
@ -1536,7 +1536,11 @@ impl Parser {
|
||||
|
||||
Expression::MethodCall { target: Box::new(lhs), method: Box::new(property), args }
|
||||
} else {
|
||||
Expression::PropertyFetch { target: Box::new(lhs), property: Box::new(property) }
|
||||
if op == &TokenKind::NullsafeArrow {
|
||||
Expression::NullsafePropertyFetch { target: Box::new(lhs), property: Box::new(property) }
|
||||
} else {
|
||||
Expression::PropertyFetch { target: Box::new(lhs), property: Box::new(property) }
|
||||
}
|
||||
}
|
||||
},
|
||||
TokenKind::Increment => {
|
||||
@ -1610,7 +1614,7 @@ fn postfix_binding_power(t: &TokenKind) -> Option<u8> {
|
||||
Some(match t {
|
||||
TokenKind::Increment | TokenKind::Decrement => 77,
|
||||
TokenKind::LeftParen | TokenKind::LeftBracket => 19,
|
||||
TokenKind::Arrow | TokenKind::DoubleColon => 18,
|
||||
TokenKind::Arrow | TokenKind::NullsafeArrow | TokenKind::DoubleColon => 18,
|
||||
TokenKind::Coalesce => 11,
|
||||
_ => return None
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user