summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
authorJJ2023-04-06 21:24:38 +0000
committerJJ2023-04-06 21:24:38 +0000
commit95ce33948581a10c2d55793b6317c7ce273f936a (patch)
tree410383a56b51af9644fa309bbe3f03d9d2368bb6 /src/ast.rs
parent3188a0ec2174945a6b004db78b534f80c7927796 (diff)
rename project, write parser tests
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 9202968..4bbc7ed 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -19,7 +19,7 @@ pub enum Expression {
// _every_ type in our language is represented as this and interpreted as a type.
// how to store more data than fits... hmm
-pub type Value = i8;
+pub type Value = u64;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Type {
@@ -27,6 +27,7 @@ pub enum Type {
Unit,
Bool,
Natural,
+ Integer,
// Float,
// String,
// Enum(Vec<Type>),
@@ -44,12 +45,12 @@ pub struct Term {
impl fmt::Debug for Expression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Expression::Annotation { expr, kind } => write!(f, "{:?}:{:?}", expr, kind),
- Expression::Constant { term } => write!(f, "{}", term.val),
+ Expression::Annotation { expr, kind } => write!(f, "({:?}: {:?})", expr, kind),
+ Expression::Constant { term } => write!(f, "'{}", term.val),
Expression::Variable { id } => write!(f, "{}", id),
Expression::Abstraction { param, func } => write!(f, "(λ{}.{:?})", param, func),
- Expression::Application { func, arg } => write!(f, "{:?} {:?}", func, arg),
- Expression::Conditional { if_cond, if_then, if_else } => write!(f, "if {:?} then {:?} else {:?}", if_cond, if_then, if_else),
+ Expression::Application { func, arg } => write!(f, "({:?} {:?})", func, arg),
+ Expression::Conditional { if_cond, if_then, if_else } => write!(f, "(if {:?} then {:?} else {:?})", if_cond, if_then, if_else),
}
}
}