From 6f16f07d90eb858799402b00749fc23514edfdcf Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 5 Mar 2019 23:36:37 +0100 Subject: Merge binary operations in AST --- dhall/src/grammar.lalrpop | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'dhall/src/grammar.lalrpop') diff --git a/dhall/src/grammar.lalrpop b/dhall/src/grammar.lalrpop index 6f87e6e..1ffe2ff 100644 --- a/dhall/src/grammar.lalrpop +++ b/dhall/src/grammar.lalrpop @@ -7,6 +7,7 @@ use crate::core::bx; use crate::core::Expr::*; use crate::core::Builtin; use crate::core::Builtin::*; +use crate::core::BinOp::*; use crate::grammar_util::*; use crate::lexer::*; @@ -77,14 +78,14 @@ ListLike: ExprListFn<'input> = { Optional => OptionalLit, }; -BoolOr: ExprOpFn<'input> = { "||" => BoolOr }; -NaturalPlus: ExprOpFn<'input> = { "+" => NaturalPlus }; -TextAppend: ExprOpFn<'input> = { "++" => TextAppend }; -BoolAnd: ExprOpFn<'input> = { "&&" => BoolAnd }; -CombineOp: ExprOpFn<'input> = { Combine => Combine }; -NaturalTimes: ExprOpFn<'input> = { "*" => NaturalTimes }; -BoolEQ: ExprOpFn<'input> = { "==" => BoolEQ }; -BoolNE: ExprOpFn<'input> = { "!=" => BoolNE }; +BoolOr: ExprOpFn<'input> = { "||" => (|x,y| BinOp(BoolOr, x, y)) }; +NaturalPlus: ExprOpFn<'input> = { "+" => (|x,y| BinOp(NaturalPlus, x, y)) }; +TextAppend: ExprOpFn<'input> = { "++" => (|x,y| BinOp(TextAppend, x, y)) }; +BoolAnd: ExprOpFn<'input> = { "&&" => (|x,y| BinOp(BoolAnd, x, y)) }; +CombineOp: ExprOpFn<'input> = { Combine => (|x,y| BinOp(Combine, x, y)) }; +NaturalTimes: ExprOpFn<'input> = { "*" => (|x,y| BinOp(NaturalTimes, x, y)) }; +BoolEQ: ExprOpFn<'input> = { "==" => (|x,y| BinOp(BoolEQ, x, y)) }; +BoolNE: ExprOpFn<'input> = { "!=" => (|x,y| BinOp(BoolNE, x, y)) }; Tier: BoxExpr<'input> = { > => bx(f(a, b)), -- cgit v1.2.3