summaryrefslogtreecommitdiff
path: root/dhall/src/grammar.lalrpop
diff options
context:
space:
mode:
authorNadrieril2019-03-05 23:36:37 +0100
committerNadrieril2019-03-05 23:36:37 +0100
commit6f16f07d90eb858799402b00749fc23514edfdcf (patch)
tree963ebaca278831b7e5385f81037ff5e40c4017c5 /dhall/src/grammar.lalrpop
parent9a0cba9d622cba67bbdd97994ab86c7d71c0b456 (diff)
Merge binary operations in AST
Diffstat (limited to '')
-rw-r--r--dhall/src/grammar.lalrpop17
1 files changed, 9 insertions, 8 deletions
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<NextTier, Op>: BoxExpr<'input> = {
<a:NextTier> <f:Op> <b:Tier<NextTier, Op>> => bx(f(a, b)),