summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/text/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/syntax/text/parser.rs')
-rw-r--r--dhall/src/syntax/text/parser.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index 8d571c0..f3ebd2b 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -5,23 +5,20 @@ use std::rc::Rc;
use pest_consume::{match_nodes, Parser};
-use crate::syntax;
use crate::syntax::map::{DupTreeMap, DupTreeSet};
use crate::syntax::ExprKind::*;
+use crate::syntax::LitKind::*;
use crate::syntax::{
- Double, FilePath, FilePrefix, Hash, ImportLocation, ImportMode, Integer,
- InterpolatedText, InterpolatedTextContents, Label, NaiveDouble, Natural,
- Scheme, Span, URL, V,
+ Double, Expr, FilePath, FilePrefix, Hash, ImportLocation, ImportMode,
+ Integer, InterpolatedText, InterpolatedTextContents, Label, NaiveDouble,
+ Natural, Scheme, Span, UnspannedExpr, URL, V,
};
-use crate::Normalized;
// This file consumes the parse tree generated by pest and turns it into
// our own AST. All those custom macros should eventually moved into
// their own crate because they are quite general and useful. For now they
// are here and hopefully you can figure out how they work.
-type Expr = syntax::Expr<Normalized>;
-type UnspannedExpr = syntax::UnspannedExpr<Normalized>;
type ParsedText = InterpolatedText<Expr>;
type ParsedTextContents = InterpolatedTextContents<Expr>;
type ParseInput<'input> = pest_consume::Node<'input, Rule, Rc<str>>;
@@ -348,8 +345,8 @@ impl DhallParser {
let e = match crate::syntax::Builtin::parse(s) {
Some(b) => Builtin(b),
None => match s {
- "True" => BoolLit(true),
- "False" => BoolLit(false),
+ "True" => Lit(Bool(true)),
+ "False" => Lit(Bool(false)),
"Type" => Const(crate::syntax::Const::Type),
"Kind" => Const(crate::syntax::Const::Kind),
"Sort" => Const(crate::syntax::Const::Sort),
@@ -837,9 +834,9 @@ impl DhallParser {
#[alias(expression, shortcut = true)]
fn primitive_expression(input: ParseInput) -> ParseResult<Expr> {
Ok(match_nodes!(input.children();
- [double_literal(n)] => spanned(input, DoubleLit(n)),
- [natural_literal(n)] => spanned(input, NaturalLit(n)),
- [integer_literal(n)] => spanned(input, IntegerLit(n)),
+ [double_literal(n)] => spanned(input, Lit(Double(n))),
+ [natural_literal(n)] => spanned(input, Lit(Natural(n))),
+ [integer_literal(n)] => spanned(input, Lit(Integer(n))),
[double_quote_literal(s)] => spanned(input, TextLit(s)),
[single_quote_literal(s)] => spanned(input, TextLit(s)),
[record_type_or_literal(e)] => spanned(input, e),