Parse positive numeric literals

This commit is contained in:
Joscha 2022-11-17 16:52:37 +01:00
parent f1eca2be57
commit 7f0f886fb7
2 changed files with 62 additions and 6 deletions

View file

@ -1,18 +1,22 @@
#[derive(Debug, Clone)]
pub struct Ident(pub String);
/// Positive number literal.
///
/// Possible bases are binary, decimal, hexadecimal. Underscores can be inserted
/// before and after any digit.
#[derive(Debug, Clone)]
pub enum NumLit {
/// - `0b_0001_1011`
/// - `-0b10`
/// - `0b10`
Bin(i64, String),
/// - `12_345`
/// - `-7`
/// - `7`
Dec(i64, String),
/// - `0x_c0_f3`
/// - `-0xB`
/// - `0xB`
Hex(i64, String),
}