mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
parser: support /=
This commit is contained in:
parent
a83f1b80bb
commit
0627e05642
@ -575,9 +575,13 @@ impl Lexer {
|
||||
} else {
|
||||
TokenKind::Comment(buffer)
|
||||
}
|
||||
} else if let Some('=') = self.peek {
|
||||
self.col += 1;
|
||||
self.next();
|
||||
TokenKind::SlashEquals
|
||||
} else if char == '/' && let Some(t) = self.peek && t != '/' {
|
||||
TokenKind::Slash
|
||||
} else if char == '#' && let Some(t) = self.peek && t == '[' {
|
||||
} else if char == '#' && let Some('[') = self.peek {
|
||||
TokenKind::Attribute
|
||||
} else {
|
||||
self.next();
|
||||
|
@ -129,6 +129,7 @@ pub enum TokenKind {
|
||||
RightParen,
|
||||
SemiColon,
|
||||
Slash,
|
||||
SlashEquals,
|
||||
Static,
|
||||
StringCast,
|
||||
Switch,
|
||||
@ -276,6 +277,7 @@ impl Display for TokenKind {
|
||||
Self::RightParen => ")",
|
||||
Self::SemiColon => ";",
|
||||
Self::Slash => "/",
|
||||
Self::SlashEquals => "/=",
|
||||
Self::Static => "static",
|
||||
Self::StringCast => "(string)",
|
||||
Self::Switch => "switch",
|
||||
|
@ -521,6 +521,7 @@ pub enum InfixOp {
|
||||
CoalesceAssign,
|
||||
MulAssign,
|
||||
SubAssign,
|
||||
DivAssign,
|
||||
}
|
||||
|
||||
impl From<TokenKind> for InfixOp {
|
||||
@ -549,6 +550,7 @@ impl From<TokenKind> for InfixOp {
|
||||
TokenKind::CoalesceEqual => Self::CoalesceAssign,
|
||||
TokenKind::AsteriskEqual => Self::MulAssign,
|
||||
TokenKind::MinusEquals => Self::SubAssign,
|
||||
TokenKind::SlashEquals => Self::DivAssign,
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
@ -1664,7 +1664,7 @@ fn infix_binding_power(t: &TokenKind) -> Option<(u8, u8)> {
|
||||
TokenKind::Question | TokenKind::QuestionColon => (6, 7),
|
||||
TokenKind::BooleanAnd => (4, 5),
|
||||
TokenKind::BooleanOr => (2, 3),
|
||||
TokenKind::Equals | TokenKind::PlusEquals | TokenKind::MinusEquals | TokenKind::DotEquals | TokenKind::CoalesceEqual | TokenKind::AsteriskEqual => (0, 1),
|
||||
TokenKind::Equals | TokenKind::PlusEquals | TokenKind::MinusEquals | TokenKind::DotEquals | TokenKind::CoalesceEqual | TokenKind::AsteriskEqual | TokenKind::SlashEquals => (0, 1),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user