Integers can be written in other bases. Today you parse the three prefixed forms, hexadecimal, octal, and binary, so config can express masks and permissions naturally.
Parse 0x, 0o, and 0b prefixed integers into their decimal values.
Beyond base ten, TOML writes integers in three other bases with a two-character
prefix: 0x for hexadecimal, 0o for octal, and 0b for binary. So a
color mask is 0xDEAD (which is 57005 in decimal), a Unix file mode is 0o755
(493), and a small bit pattern is 0b1010 (10). These prefixes make intent obvious
where a plain decimal would obscure it.
Parsing is the decimal path with a twist: recognize the prefix, then interpret the
remaining digits in that base. Hex digits are case-insensitive, so 0xDEAD and
0xdead are equal, and underscores between digits are still allowed for grouping
(0xdead_beef is 3735928559). One difference from decimal: a prefixed integer
never carries a sign - there is no -0x1 - because these forms are about bit
patterns, not signed magnitudes. Detecting the prefix and switching base is the
whole job.
// after the bare token is read, check a two-char prefix:// "0x" -> base 16 "0o" -> base 8 "0b" -> base 2// strip the prefix and inter-digit underscores, then parse in that base// no leading sign is allowed on a prefixed integer