Parse positive numeric literals
This commit is contained in:
parent
f1eca2be57
commit
7f0f886fb7
2 changed files with 62 additions and 6 deletions
10
src/ast.rs
10
src/ast.rs
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue