From 492ef4ae199c9293ec1d0a2ea00fc38fbad4635d Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 19 Aug 2018 15:03:41 -0700 Subject: [PATCH] Clear up some unused code to reduce compile noise And add some notes to the README --- README.md | 2 ++ schala-lang/src/builtin.rs | 4 ++++ schala-lang/src/reduced_ast.rs | 14 +++++++------- schala-lang/src/typechecking.rs | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f726c3d..4b29645 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ of learning how to write a programming language. ### Type-checking https://skillsmatter.com/skillscasts/10868-inside-the-rust-compiler +https://www.youtube.com/watch?v=il3gD7XMdmA +http://dev.stephendiehl.com/fun/006_hindley_milner.html ### Evaluation *Understanding Computation*, Tom Stuart, O'Reilly 2013 diff --git a/schala-lang/src/builtin.rs b/schala-lang/src/builtin.rs index b30a0c2..81291d7 100644 --- a/schala-lang/src/builtin.rs +++ b/schala-lang/src/builtin.rs @@ -39,10 +39,12 @@ impl BinOp { pub fn sigil(&self) -> &Rc { &self.sigil } + /* pub fn get_type(&self) -> Result { let s = self.sigil.as_str(); BINOPS.get(s).map(|x| x.0.clone()).ok_or(format!("Binop {} not found", s)) } + */ pub fn min_precedence() -> i32 { i32::min_value() } @@ -67,10 +69,12 @@ impl PrefixOp { pub fn is_prefix(op: &str) -> bool { PREFIX_OPS.get(op).is_some() } + /* pub fn get_type(&self) -> Result { let s = self.sigil.as_str(); PREFIX_OPS.get(s).map(|x| x.0.clone()).ok_or(format!("Prefix op {} not found", s)) } + */ } lazy_static! { static ref PREFIX_OPS: HashMap<&'static str, (Type, ())> = diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 38bb8fb..54999e6 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -196,22 +196,22 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, Guard::Pat(ref p) => match p { Pattern::Ignored => (None, vec![]), Pattern::Literal(lit) => match lit { - PatternLiteral::NumPattern(expr) => unimplemented!(), - PatternLiteral::StringPattern(s) => unimplemented!(), - PatternLiteral::BoolPattern(b) => unimplemented!(), - PatternLiteral::VarPattern(var) => unimplemented!(), + PatternLiteral::NumPattern(_expr) => unimplemented!(), + PatternLiteral::StringPattern(_s) => unimplemented!(), + PatternLiteral::BoolPattern(_b) => unimplemented!(), + PatternLiteral::VarPattern(_var) => unimplemented!(), }, Pattern::TuplePattern(_) => { unimplemented!() }, - Pattern::TupleStruct(name, subpatterns) => { + Pattern::TupleStruct(_name, _subpatterns) => { unimplemented!() }, - Pattern::Record(name, pairs) => { + Pattern::Record(_name, _pairs) => { unimplemented!() }, }, - Guard::HalfExpr(HalfExpr { ref op, ref expr }) => { + Guard::HalfExpr(HalfExpr { op: _, expr: _ }) => { (Some(0), vec![]) } diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index a25c8d3..f8ce6bf 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -28,7 +28,7 @@ enum TConst { Unit, Nat, StringT, - Custom(String) + //Custom(String) } #[derive(Debug, PartialEq, Clone)]