From 78e9e32e1357d50313287dd2a3c437132c83aeb6 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 15 Dec 2019 20:10:54 +0000 Subject: Move contents of dhall_syntax to dhall --- dhall/src/syntax/parser.rs | 942 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 942 insertions(+) create mode 100644 dhall/src/syntax/parser.rs (limited to 'dhall/src/syntax/parser.rs') diff --git a/dhall/src/syntax/parser.rs b/dhall/src/syntax/parser.rs new file mode 100644 index 0000000..2f589fe --- /dev/null +++ b/dhall/src/syntax/parser.rs @@ -0,0 +1,942 @@ +use itertools::Itertools; +use pest::prec_climber as pcl; +use pest::prec_climber::PrecClimber; +use std::rc::Rc; + +use pest_consume::{match_nodes, Parser}; + +use crate::syntax::map::{DupTreeMap, DupTreeSet}; +use crate::syntax::ExprF::*; +use crate::syntax::*; + +// 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 ParsedText = InterpolatedText>; +type ParsedTextContents = InterpolatedTextContents>; +type ParseInput<'input> = pest_consume::Node<'input, Rule, Rc>; + +pub type ParseError = pest::error::Error; +pub type ParseResult = Result; + +#[derive(Debug)] +enum Selector { + Field(Label), + Projection(DupTreeSet