Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/expressions/atom.rs')
| -rw-r--r-- | crates/parser/src/grammar/expressions/atom.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 07b0a2aee5..d7a0691717 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -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(&[ |