Numbers

Int

Int = hexadecimal_number
    | octal_number
    | binary_number
    | decimal_number

hexadecimal_number = "0", ("x" | "X"), hexadecimal_digit+
decimal_number     = decimal_digit+
octal_number       = "0", ("o" | "O"), octal_digit+
binary_number      = "0", "b", binary_digit +
12345
01234   // This is a decimal number, not an octal number
0o755   // This is octal
0b0110
0xff25
0xFfaAthp
    

TODO: Allow underscores _ between any number: 1_000_000.

TODO: Make it an error to have a number start with a leading zero, to eliminate confusion with proper octal and legacy PHP octal.

Float

Float = decimal_number, ".", decimal_number+, scientific_notation?
      | decimal_number, scientific_notation

scientific_notation = "e", ("+" | "-"), decimal_number
123.456
123.456e+4
123.456e-2

123e+10
123e-3thp
    

All floating point numbers must start with at least 1 digit. .5 is not a valid floating point number.

TODO: Allow scientific notation to omit the +/-: 10e4.