mirror of
https://github.com/danog/parser.git
synced 2025-01-22 21:11:55 +01:00
parser: roughly support inc/dec postfix ops
This commit is contained in:
parent
983c6edbd3
commit
e17d66e2d8
@ -320,6 +320,12 @@ pub struct Use {
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Serialize)]
|
||||
pub enum Expression {
|
||||
Increment {
|
||||
value: Box<Self>,
|
||||
},
|
||||
Decrement {
|
||||
value: Box<Self>,
|
||||
},
|
||||
Int {
|
||||
i: i64
|
||||
},
|
||||
|
@ -1436,6 +1436,12 @@ impl Parser {
|
||||
Expression::PropertyFetch { target: Box::new(lhs), property: property.into() }
|
||||
}
|
||||
},
|
||||
TokenKind::Increment => {
|
||||
Expression::Increment { value: Box::new(lhs) }
|
||||
},
|
||||
TokenKind::Decrement => {
|
||||
Expression::Decrement { value: Box::new(lhs) }
|
||||
},
|
||||
_ => todo!("postfix: {:?}", op),
|
||||
})
|
||||
}
|
||||
@ -1499,6 +1505,7 @@ fn infix_binding_power(t: &TokenKind) -> Option<(u8, u8)> {
|
||||
|
||||
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::Coalesce => 11,
|
||||
|
Loading…
x
Reference in New Issue
Block a user