mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Wrap floats in token trees in FLOAT_LITERAL
node
This commit is contained in:
parent
90bd99f1bb
commit
34dc8e9383
6 changed files with 33 additions and 22 deletions
|
@ -30,16 +30,7 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
}
|
||||
let m = p.start();
|
||||
if p.at(FLOAT_NUMBER_PART) {
|
||||
// Floats can be up to 3 tokens: 2 `FLOAT_NUMBER_PART`s separated by 1 `DOT`
|
||||
let f = p.start();
|
||||
p.bump(FLOAT_NUMBER_PART);
|
||||
if p.at(DOT) {
|
||||
p.bump(DOT);
|
||||
if p.at(FLOAT_NUMBER_PART) {
|
||||
p.bump(FLOAT_NUMBER_PART);
|
||||
}
|
||||
}
|
||||
f.complete(p, FLOAT_LITERAL);
|
||||
float_literal(p);
|
||||
} else {
|
||||
// Everything else is just one token.
|
||||
p.bump_any();
|
||||
|
@ -47,6 +38,19 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||
Some(m.complete(p, LITERAL))
|
||||
}
|
||||
|
||||
pub(crate) fn float_literal(p: &mut Parser) {
|
||||
// Floats can be up to 3 tokens: 2 `FLOAT_NUMBER_PART`s separated by 1 `DOT`
|
||||
let f = p.start();
|
||||
p.bump(FLOAT_NUMBER_PART);
|
||||
if p.at(DOT) {
|
||||
p.bump(DOT);
|
||||
if p.at(FLOAT_NUMBER_PART) {
|
||||
p.bump(FLOAT_NUMBER_PART);
|
||||
}
|
||||
}
|
||||
f.complete(p, FLOAT_LITERAL);
|
||||
}
|
||||
|
||||
// E.g. for after the break in `if break {}`, this should not match
|
||||
pub(super) const ATOM_EXPR_FIRST: TokenSet =
|
||||
LITERAL_FIRST.union(paths::PATH_FIRST).union(TokenSet::new(&[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue