summaryrefslogtreecommitdiff
path: root/dhall/src/grammar_util.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-01 17:28:19 +0100
committerNadrieril2019-03-01 17:28:19 +0100
commite5d9aee00b0c775df1d8e2d8819aeb80dffa73c2 (patch)
treee763a24a0d635048232e72e167ca37eafec69369 /dhall/src/grammar_util.rs
parent8a2b7536902831079eddd7b00291b718f5dd7186 (diff)
Split abnf_to_pest and dhall into their own crates
Diffstat (limited to 'dhall/src/grammar_util.rs')
-rw-r--r--dhall/src/grammar_util.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/dhall/src/grammar_util.rs b/dhall/src/grammar_util.rs
new file mode 100644
index 0000000..c546a13
--- /dev/null
+++ b/dhall/src/grammar_util.rs
@@ -0,0 +1,14 @@
+use crate::core::{Expr, X};
+use crate::lexer::Builtin;
+
+pub type ParsedExpr<'i> = Expr<'i, X, X>; // FIXME Parse paths and replace the second X with Path
+pub type BoxExpr<'i> = Box<ParsedExpr<'i>>;
+pub type ExprOpFn<'i> = fn(BoxExpr<'i>, BoxExpr<'i>) -> ParsedExpr<'i>;
+pub type ExprListFn<'i> = fn(BoxExpr<'i>, Vec<ParsedExpr<'i>>) -> ParsedExpr<'i>;
+
+pub fn builtin_expr<'i, S, A>(b: Builtin) -> Expr<'i, S, A> {
+ match b {
+ Builtin::Type(t) => Expr::BuiltinType(t),
+ Builtin::Value(v) => Expr::BuiltinValue(v),
+ }
+}