mirror of
https://github.com/danog/parser.git
synced 2024-11-27 12:24:57 +01:00
parser: add associativity mappings
This commit is contained in:
parent
f4de25d2dc
commit
be4e54c5be
@ -81,10 +81,31 @@ impl Precedence {
|
|||||||
_ => unimplemented!("postfix precedence for op {:?}", kind),
|
_ => unimplemented!("postfix precedence for op {:?}", kind),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn associativity(&self) -> Option<Associativity> {
|
||||||
|
Some(match self {
|
||||||
|
Self::Instanceof
|
||||||
|
| Self::MulDivMod
|
||||||
|
| Self::AddSub
|
||||||
|
| Self::BitShift
|
||||||
|
| Self::Concat
|
||||||
|
| Self::BitwiseAnd
|
||||||
|
| Self::BitwiseOr
|
||||||
|
| Self::BitwiseXor
|
||||||
|
| Self::And
|
||||||
|
| Self::Or
|
||||||
|
| Self::KeyAnd
|
||||||
|
| Self::KeyOr
|
||||||
|
| Self::KeyXor => Associativity::Left,
|
||||||
|
Self::Pow | Self::NullCoalesce | Self::Assignment => Associativity::Right,
|
||||||
|
Self::Ternary | Self::Equality | Self::LtGt => Associativity::Non,
|
||||||
|
_ => return None,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Associativity {
|
pub enum Associativity {
|
||||||
None,
|
Non,
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user