Skip to main content

try_consume_number_literal

Function try_consume_number_literal 

Source
pub fn try_consume_number_literal(lexer: &mut Lexer) -> Option<Token>
Available on crate feature lexer only.
Expand description

Attempt to lex and consume a TokenTy::IntegerLiteral or TokenTy::FloatLiteral from the lexer.

Integer literals may have a radix prefix (0x, 0X, 0o, 0b, 0B) and may contain underscores after their first digit. Float literals are always decimal, and have a fractional part (1.5), an exponent (1e10), or both (1.5e-3). A . is only considered part of a float if it is followed by a decimal digit, so 1..2 and 1.foo lex the way you would expect.