From 1b1c34b90bb4bf3859b05b1da6db2dcb374996bb Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 14:58:18 +0200 Subject: Move `Note`s into the spine of the AST --- dhall_syntax/src/core.rs | 69 ++++++------- dhall_syntax/src/parser.rs | 2 +- dhall_syntax/src/printer.rs | 10 +- dhall_syntax/src/visitor.rs | 234 ++++++++++---------------------------------- 4 files changed, 80 insertions(+), 235 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/src/core.rs b/dhall_syntax/src/core.rs index 3db07dd..a81f96c 100644 --- a/dhall_syntax/src/core.rs +++ b/dhall_syntax/src/core.rs @@ -141,17 +141,25 @@ pub type ParsedExpr = SubExpr; pub type ResolvedExpr = SubExpr; pub type DhallExpr = ResolvedExpr; -#[derive(Debug, PartialEq, Eq)] -pub struct SubExpr(pub Rc>); +#[derive(Debug)] +pub struct SubExpr(Rc>, Option); -pub type Expr = ExprF, Label, Note, Embed>; +impl std::cmp::PartialEq for SubExpr { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl std::cmp::Eq for SubExpr {} + +pub type Expr = ExprF, Label, Embed>; /// Syntax tree for expressions // Having the recursion out of the enum definition enables writing // much more generic code and improves pattern-matching behind // smart pointers. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ExprF { +pub enum ExprF { Const(Const), /// `x` /// `x@n` @@ -208,28 +216,25 @@ pub enum ExprF { Field(SubExpr, Label), /// `e.{ x, y, z }` Projection(SubExpr, Vec