summaryrefslogtreecommitdiff
path: root/src/syntax/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/syntax/ast.rs')
-rw-r--r--src/syntax/ast.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index 4abf51d9..d718ccf0 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -912,7 +912,17 @@ node! {
impl Int {
/// Get the integer value.
pub fn get(&self) -> i64 {
- self.0.text().parse().unwrap_or_default()
+ let text = self.0.text();
+ if let Some(rest) = text.strip_prefix("0x") {
+ i64::from_str_radix(rest, 16)
+ } else if let Some(rest) = text.strip_prefix("0o") {
+ i64::from_str_radix(rest, 8)
+ } else if let Some(rest) = text.strip_prefix("0b") {
+ i64::from_str_radix(rest, 2)
+ } else {
+ text.parse()
+ }
+ .unwrap_or_default()
}
}