diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 5c4cd46..af05769 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -274,7 +274,8 @@ impl NarrowedShape { } } -#[doc = "Shapes represent the types that UCG values or expressions can have."] +// TODO(jwall): Display implementations for shapes. +/// Shapes represent the types that UCG values or expressions can have. #[derive(PartialEq, Debug, Clone)] pub enum Shape { Empty(Position), @@ -309,12 +310,10 @@ impl Shape { self.narrow_tuple_shapes(left_slist, right_slist, right) } (Shape::Func(left_opshape), Shape::Func(right_opshape)) => { - // TODO - unimplemented!("Can't merge these yet."); + todo!(); } (Shape::Module(left_opshape), Shape::Module(right_opshape)) => { - // TODO - unimplemented!("Can't merge these yet."); + todo!(); } _ => Shape::TypeErr( right.pos().clone(), diff --git a/src/ast/typecheck/mod.rs b/src/ast/typecheck/mod.rs index e3808f5..51e02f7 100644 --- a/src/ast/typecheck/mod.rs +++ b/src/ast/typecheck/mod.rs @@ -20,7 +20,9 @@ use crate::ast::walk::Visitor; use crate::ast::{Expression, FailDef, ImportDef, IncludeDef, Shape, Statement, Value}; use crate::error::{BuildError, ErrorType}; -use super::{PositionedItem, NarrowedShape, ImportShape, CastType, NotDef, CopyDef, ModuleShape, FuncDef}; +use super::{ + CastType, CopyDef, FuncDef, ImportShape, ModuleShape, NarrowedShape, NotDef, PositionedItem, +}; /// Trait for shape derivation. pub trait DeriveShape { @@ -171,9 +173,7 @@ impl DeriveShape for Expression { fn derive_shape(&self, symbol_table: &mut BTreeMap, Shape>) -> Shape { match self { Expression::Simple(v) => v.derive_shape(symbol_table), - Expression::Format(def) => { - Shape::Str(PositionedItem::new("".into(), def.pos.clone())) - } + Expression::Format(def) => Shape::Str(PositionedItem::new("".into(), def.pos.clone())), Expression::Not(def) => derive_not_shape(def, symbol_table), Expression::Grouped(v, _pos) => v.as_ref().derive_shape(symbol_table), Expression::Range(def) => Shape::List(NarrowedShape::new_with_pos( @@ -247,6 +247,14 @@ pub struct Checker { shape_stack: Vec, } +// TODO(jwall): I am beginning to suspect that derive_shape should be a Trait. +// It would allow me to specify the contract a little more specifically now that +// I'm basically implementing the method all over the place. + +// TODO(jwall): The symbol table contract also needs to be fleshed out a little better. +// I need to acccount for scopes syntactic scopes a bit. packages, functions and modules all are a +// factor. + impl Checker { pub fn new() -> Self { return Self { @@ -295,7 +303,6 @@ impl Visitor for Checker { } fn visit_value(&mut self, val: &mut Value) { - // TODO(jwall): Some values can contain expressions. Handle those here. match val { Value::Empty(p) => self.shape_stack.push(Shape::Empty(p.clone())), Value::Boolean(p) => self.shape_stack.push(Shape::Boolean(p.clone())), diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs index ef8736b..5506f1c 100644 --- a/src/tokenizer/mod.rs +++ b/src/tokenizer/mod.rs @@ -14,7 +14,6 @@ //! The tokenization stage of the ucg compiler. use std; -use std::rc::Rc; use abortable_parser::combinators::*; use abortable_parser::iter::SliceIter;