Module number

Source
Expand description

Number parsing for the AIM expression grammar.

This module provides parsers for numeric literals in the AIM expression language, supporting integers, floating-point numbers, and scientific notation. It handles common number formats with flexible syntax to accommodate various user input styles.

§Supported Number Formats

  • Integers: 123, -456, 0
  • Floats: 12.34, -56.78, .5, -.5, 123.
  • Scientific notation: 1e10, 2.5e-3, -1.2E+4, 5E2
  • Special values: NaN, Inf, +Inf, -Inf

§Examples

42          // integer
-3.14       // float
.5          // float without leading zero
1e6         // scientific notation
-2.5E-3     // scientific notation with negative exponent
NaN         // not a number
Inf         // positive infinity
-Inf        // negative infinity

Functions§

parse_number
Parse a number literal from a string into an f64 value.
parse_unsigned
Parse an unsigned 32-bit integer from a string.