From 95ce33948581a10c2d55793b6317c7ce273f936a Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 6 Apr 2023 14:24:38 -0700 Subject: rename project, write parser tests --- src/ast.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ast.rs') 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), @@ -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), } } } -- cgit v1.2.3-70-g09d2