From 08e1d8ece4314b56d64fa08595c2e043b97896d1 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 Apr 2020 17:19:31 +0100 Subject: Split off operations from main expr enum --- dhall/src/syntax/ast/expr.rs | 121 ++++++++++++++++++++++---------- dhall/src/syntax/ast/visitor.rs | 100 ++++++++------------------- dhall/src/syntax/binary/decode.rs | 34 +++++---- dhall/src/syntax/binary/encode.rs | 33 +++++---- dhall/src/syntax/text/parser.rs | 36 +++++----- dhall/src/syntax/text/printer.rs | 141 +++++++++++++++++++++----------------- 6 files changed, 253 insertions(+), 212 deletions(-) (limited to 'dhall/src/syntax') diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs index 9e935dc..51426ce 100644 --- a/dhall/src/syntax/ast/expr.rs +++ b/dhall/src/syntax/ast/expr.rs @@ -126,63 +126,73 @@ pub enum NumKind { Double(Double), } +/// Operations +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum OpKind { + /// `f a` + App(SubExpr, SubExpr), + /// Binary operations + BinOp(BinOp, SubExpr, SubExpr), + /// `if x then y else z` + BoolIf(SubExpr, SubExpr, SubExpr), + /// `merge x y : t` + Merge(SubExpr, SubExpr, Option), + /// `toMap x : t` + ToMap(SubExpr, Option), + /// `e.x` + Field(SubExpr, Label), + /// `e.{ x, y, z }` + Projection(SubExpr, DupTreeSet