use itertools::Itertools; use pest::prec_climber as pcl; use pest::prec_climber::PrecClimber; use std::collections::{BTreeMap, BTreeSet}; use std::iter::once; use std::rc::Rc; use pest_consume::{match_nodes, Parser}; use crate::operations::OpKind::*; use crate::syntax::ExprKind::*; use crate::syntax::NumKind::*; use crate::syntax::{ Double, Expr, FilePath, FilePrefix, Hash, ImportMode, ImportTarget, Integer, InterpolatedText, InterpolatedTextContents, Label, NaiveDouble, Natural, Scheme, Span, UnspannedExpr, URL, V, }; // 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(BTreeSet