aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 11:49:51 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 11:49:51 -0400
commit752ab8212c7556ed714d1272582e57180b50c5a6 (patch)
tree50d05d8e7512494fbbe16a27ed89d6a14b401ea5 /parse.c
parent8b94c2c7f198babe64a2636538913cf67165709c (diff)
Split BigIntType out of IntType and switch to using enums for the size
of ints/nums
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/parse.c b/parse.c
index 59e41ec6..f8f1a512 100644
--- a/parse.c
+++ b/parse.c
@@ -468,11 +468,11 @@ PARSER(parse_int) {
}
match(&pos, "_");
- int64_t bits = 0;
- if (match(&pos, "i64")) bits = 64;
- else if (match(&pos, "i32")) bits = 32;
- else if (match(&pos, "i16")) bits = 16;
- else if (match(&pos, "i8")) bits = 8;
+ auto bits = IBITS_UNSPECIFIED;
+ if (match(&pos, "i64")) bits = IBITS64;
+ else if (match(&pos, "i32")) bits = IBITS32;
+ else if (match(&pos, "i16")) bits = IBITS16;
+ else if (match(&pos, "i8")) bits = IBITS8;
// else if (match(&pos, ".") || match(&pos, "e")) return NULL; // looks like a float
@@ -624,14 +624,13 @@ PARSER(parse_num) {
if (negative) d *= -1;
- int64_t bits = 64;
+ auto bits = NBITS_UNSPECIFIED;
match(&pos, "_");
- if (match(&pos, "f64")) bits = 64;
- else if (match(&pos, "f32")) bits = 32;
+ if (match(&pos, "f64")) bits = NBITS64;
+ else if (match(&pos, "f32")) bits = NBITS32;
- if (match(&pos, "%")) {
+ if (match(&pos, "%"))
d /= 100.;
- }
return NewAST(ctx->file, start, pos, Num, .n=d, .bits=bits);
}