summaryrefslogtreecommitdiff
path: root/src/syntax/tokens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax/tokens.rs')
-rw-r--r--src/syntax/tokens.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs
index 4b86c89b..e0ef2fa1 100644
--- a/src/syntax/tokens.rs
+++ b/src/syntax/tokens.rs
@@ -207,8 +207,8 @@ impl<'s> Tokens<'s> {
}
'`' => self.raw(),
c if c.is_ascii_digit() => self.numbering(start),
- '<' => self.label(),
- '@' => self.reference(start),
+ '<' if self.s.at(is_id_continue) => self.label(),
+ '@' if self.s.at(is_id_continue) => self.reference(),
// Escape sequences.
'\\' => self.backslash(),
@@ -417,13 +417,8 @@ impl<'s> Tokens<'s> {
}
}
- fn reference(&mut self, start: usize) -> SyntaxKind {
- let label = self.s.eat_while(is_id_continue);
- if !label.is_empty() {
- SyntaxKind::Ref(label.into())
- } else {
- self.text(start)
- }
+ fn reference(&mut self) -> SyntaxKind {
+ SyntaxKind::Ref(self.s.eat_while(is_id_continue).into())
}
fn math(&mut self, start: usize, c: char) -> SyntaxKind {
@@ -475,6 +470,9 @@ impl<'s> Tokens<'s> {
'(' => SyntaxKind::LeftParen,
')' => SyntaxKind::RightParen,
+ // Labels.
+ '<' if self.s.at(is_id_continue) => self.label(),
+
// Two-char operators.
'=' if self.s.eat_if('=') => SyntaxKind::EqEq,
'!' if self.s.eat_if('=') => SyntaxKind::ExclEq,
@@ -954,7 +952,7 @@ mod tests {
t!(Code: "=" => Eq);
t!(Code: "==" => EqEq);
t!(Code: "!=" => ExclEq);
- t!(Code: "<" => Lt);
+ t!(Code[" /"]: "<" => Lt);
t!(Code: "<=" => LtEq);
t!(Code: ">" => Gt);
t!(Code: ">=" => GtEq);