fix jointess for floats not being set properly

This commit is contained in:
Lukas Wirth 2023-02-07 17:41:16 +01:00
parent e59487de38
commit 27cd509558

View File

@ -43,18 +43,16 @@ impl<'a> LexedStr<'a> {
res.was_joint(); res.was_joint();
} }
res.push(kind); res.push(kind);
}
if kind == SyntaxKind::FLOAT_NUMBER {
// we set jointness for floating point numbers as a hack to inform the // we set jointness for floating point numbers as a hack to inform the
// parser about whether we have a `0.` or `0.1` style float // parser about whether we have a `0.` or `0.1` style float
if self.text(i).split_once('.').map_or(false, |(_, it)| it.is_empty()) { if kind == SyntaxKind::FLOAT_NUMBER {
was_joint = false; if !self.text(i).split_once('.').map_or(true, |(_, it)| it.is_empty()) {
} else { res.was_joint();
was_joint = true; }
} }
} else {
was_joint = true;
} }
was_joint = true;
} }
} }
res res
@ -202,7 +200,7 @@ impl Builder<'_, '_> {
(self.sink)(StrStep::Token { kind: SyntaxKind::DOT, text: "." }); (self.sink)(StrStep::Token { kind: SyntaxKind::DOT, text: "." });
if has_pseudo_dot { if has_pseudo_dot {
assert!(right.is_empty()); assert!(right.is_empty(), "{left}.{right}");
self.state = State::Normal; self.state = State::Normal;
} else { } else {
(self.sink)(StrStep::Enter { kind: SyntaxKind::NAME_REF }); (self.sink)(StrStep::Enter { kind: SyntaxKind::NAME_REF });