summaryrefslogtreecommitdiff
path: root/dhall/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/parser.rs')
-rw-r--r--dhall/src/parser.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/dhall/src/parser.rs b/dhall/src/parser.rs
index 40272e0..7a4919e 100644
--- a/dhall/src/parser.rs
+++ b/dhall/src/parser.rs
@@ -3,7 +3,7 @@ use lalrpop_util;
use crate::grammar;
use crate::grammar_util::{BoxExpr, ParsedExpr};
use crate::lexer::{Lexer, LexicalError, Tok};
-use crate::core::{bx, Expr, V};
+use crate::core::{bx, Expr, Builtin, V};
pub type ParseError<'i> = lalrpop_util::ParseError<usize, Tok<'i>, LexicalError>;
@@ -127,7 +127,14 @@ fn parse_expression(pair: Pair<Rule>) -> BoxExpr {
Rule::identifier_raw =>
parse!(pair; (name: str, idx?: natural) => {
- bx(Expr::Var(V(name, idx.unwrap_or(0))))
+ match Builtin::parse(name) {
+ Some(b) => bx(Expr::Builtin(b)),
+ None => match name {
+ "True" => bx(Expr::BoolLit(true)),
+ "False" => bx(Expr::BoolLit(false)),
+ name => bx(Expr::Var(V(name, idx.unwrap_or(0)))),
+ }
+ }
}),
Rule::ifthenelse_expression =>