Add support for multiple integer types.

This commit is contained in:
2023-06-04 17:31:26 -07:00
parent 7efd2fb796
commit 469fe35e46
19 changed files with 528 additions and 169 deletions

View File

@@ -1,3 +1,4 @@
pub use crate::syntax::tokens::ConstantType;
use crate::syntax::Location;
/// The set of valid binary operators.
@@ -76,7 +77,7 @@ impl PartialEq for Expression {
Expression::Cast(_, t1, e1) => match other {
Expression::Cast(_, t2, e2) => t1 == t2 && e1 == e2,
_ => false,
}
},
Expression::Primitive(_, prim1, args1) => match other {
Expression::Primitive(_, prim2, args2) => prim1 == prim2 && args1 == args2,
_ => false,
@@ -88,6 +89,12 @@ impl PartialEq for Expression {
/// A value from the source syntax
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Value {
/// The value of the number, and an optional base that it was written in
Number(Option<u8>, i64),
/// The value of the number, an optional base that it was written in, and any
/// type information provided.
///
/// u64 is chosen because it should be big enough to carry the amount of
/// information we need, and technically we interpret -4 as the primitive unary
/// operation "-" on the number 4. We'll translate this into a type-specific
/// number at a later time.
Number(Option<u8>, Option<ConstantType>, u64),
}