From 7d30b044a2c8c2cef8143b9e0ac763024c50026c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 24 Mar 2019 01:06:40 +0100 Subject: Refactor printer Avoids stupid stack overflows when adding variants, gets precedences right, and updates to latest grammar changes --- dhall_core/src/core.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'dhall_core/src/core.rs') diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 502a9bc..0ea8c83 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -102,32 +102,34 @@ pub enum Const { #[derive(Debug, Clone, PartialEq, Eq)] pub struct V(pub Label, pub usize); -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +// Definition order must match precedence order for +// pretty-printing to work correctly +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum BinOp { - /// x && y` - BoolAnd, + /// x ? y + ImportAlt, /// x || y` BoolOr, - /// x == y` - BoolEQ, - /// x != y` - BoolNE, /// x + y` NaturalPlus, - /// x * y` - NaturalTimes, /// x ++ y` TextAppend, + /// x # y + ListAppend, + /// x && y` + BoolAnd, /// x ∧ y` Combine, - /// x //\\ y - CombineTypes, - /// x ? y - ImportAlt, /// x // y Prefer, - /// x # y - ListAppend, + /// x //\\ y + CombineTypes, + /// x * y` + NaturalTimes, + /// x == y` + BoolEQ, + /// x != y` + BoolNE, } /// Built-ins -- cgit v1.2.3