diff options
author | Nadrieril | 2019-03-08 22:46:39 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-08 22:46:39 +0100 |
commit | d3f4a32d1e3d39c8d42306e5ca5ad4bb256edcd8 (patch) | |
tree | 113e9a9aaac158a5c0d110b3ce93c2a531957c27 /dhall_core/src | |
parent | 66bed8dbc7249e17a89adcbb19406f4126a434de (diff) |
Rename Expr back to its true name
Diffstat (limited to 'dhall_core/src')
-rw-r--r-- | dhall_core/src/core.rs | 175 | ||||
-rw-r--r-- | dhall_core/src/grammar_util.rs | 2 | ||||
-rw-r--r-- | dhall_core/src/parser.rs | 76 |
3 files changed, 126 insertions, 127 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 2465629..04c3961 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -136,9 +136,8 @@ pub enum BinOp { } /// Syntax tree for expressions -pub type Expr<'i, S, A> = Expr_<&'i str, S, A>; #[derive(Debug, Clone, PartialEq)] -pub enum Expr_<Label, Note, Embed> { +pub enum Expr<Label, Note, Embed> { /// `Const c ~ c` Const(Const), /// `Var (V x 0) ~ x`<br> @@ -147,49 +146,49 @@ pub enum Expr_<Label, Note, Embed> { /// `Lam x A b ~ λ(x : A) -> b` Lam( Label, - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `Pi "_" A B ~ A -> B` /// `Pi x A B ~ ∀(x : A) -> B` Pi( Label, - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `App f A ~ f A` App( - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `Let x Nothing r e ~ let x = r in e` /// `Let x (Just t) r e ~ let x : t = r in e` Let( Label, - Option<Box<Expr_<Label, Note, Embed>>>, - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Option<Box<Expr<Label, Note, Embed>>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `Annot x t ~ x : t` Annot( - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// Built-in values Builtin(Builtin), // Binary operations BinOp( BinOp, - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `BoolLit b ~ b` BoolLit(bool), /// `BoolIf x y z ~ if x then y else z` BoolIf( - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, ), /// `NaturalLit n ~ +n` NaturalLit(Natural), @@ -201,37 +200,37 @@ pub enum Expr_<Label, Note, Embed> { TextLit(Builder), /// `ListLit t [x, y, z] ~ [x, y, z] : List t` ListLit( - Option<Box<Expr_<Label, Note, Embed>>>, - Vec<Expr_<Label, Note, Embed>>, + Option<Box<Expr<Label, Note, Embed>>>, + Vec<Expr<Label, Note, Embed>>, ), /// `OptionalLit t [e] ~ [e] : Optional t` /// `OptionalLit t [] ~ [] : Optional t` OptionalLit( - Option<Box<Expr_<Label, Note, Embed>>>, - Vec<Expr_<Label, Note, Embed>>, + Option<Box<Expr<Label, Note, Embed>>>, + Vec<Expr<Label, Note, Embed>>, ), /// `Record [(k1, t1), (k2, t2)] ~ { k1 : t1, k2 : t1 }` - Record(BTreeMap<Label, Expr_<Label, Note, Embed>>), + Record(BTreeMap<Label, Expr<Label, Note, Embed>>), /// `RecordLit [(k1, v1), (k2, v2)] ~ { k1 = v1, k2 = v2 }` - RecordLit(BTreeMap<Label, Expr_<Label, Note, Embed>>), + RecordLit(BTreeMap<Label, Expr<Label, Note, Embed>>), /// `Union [(k1, t1), (k2, t2)] ~ < k1 : t1, k2 : t2 >` - Union(BTreeMap<Label, Expr_<Label, Note, Embed>>), + Union(BTreeMap<Label, Expr<Label, Note, Embed>>), /// `UnionLit (k1, v1) [(k2, t2), (k3, t3)] ~ < k1 = t1, k2 : t2, k3 : t3 >` UnionLit( Label, - Box<Expr_<Label, Note, Embed>>, - BTreeMap<Label, Expr_<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + BTreeMap<Label, Expr<Label, Note, Embed>>, ), /// `Merge x y t ~ merge x y : t` Merge( - Box<Expr_<Label, Note, Embed>>, - Box<Expr_<Label, Note, Embed>>, - Option<Box<Expr_<Label, Note, Embed>>>, + Box<Expr<Label, Note, Embed>>, + Box<Expr<Label, Note, Embed>>, + Option<Box<Expr<Label, Note, Embed>>>, ), /// `Field e x ~ e.x` - Field(Box<Expr_<Label, Note, Embed>>, Label), + Field(Box<Expr<Label, Note, Embed>>, Label), /// Annotation on the AST. Unused for now but could hold e.g. file location information - Note(Note, Box<Expr_<Label, Note, Embed>>), + Note(Note, Box<Expr<Label, Note, Embed>>), /// Embeds an import or the result of resolving the import Embed(Embed), } @@ -291,32 +290,32 @@ impl<Label> From<Label> for V<Label> { } } -impl<'i, S, A> From<&'i str> for Expr<'i, S, A> { +impl<'i, S, A> From<&'i str> for Expr<&'i str, S, A> { fn from(s: &'i str) -> Self { - Expr_::Var(s.into()) + Expr::Var(s.into()) } } -impl<L, S, A> From<Builtin> for Expr_<L, S, A> { +impl<L, S, A> From<Builtin> for Expr<L, S, A> { fn from(t: Builtin) -> Self { - Expr_::Builtin(t) + Expr::Builtin(t) } } -impl<Label: StringLike, S, A> Expr_<Label, S, A> { +impl<Label: StringLike, S, A> Expr<Label, S, A> { pub fn map_shallow<T, B, Label2, F1, F2, F3, F4>( &self, map_expr: F1, map_note: F2, map_embed: F3, map_label: F4, - ) -> Expr_<Label2, T, B> + ) -> Expr<Label2, T, B> where A: Clone, T: Clone, S: Clone, Label2: StringLike, - F1: Fn(&Self) -> Expr_<Label2, T, B>, + F1: Fn(&Self) -> Expr<Label2, T, B>, F2: FnOnce(&S) -> T, F3: FnOnce(&A) -> B, F4: Fn(&Label) -> Label2, @@ -324,13 +323,13 @@ impl<Label: StringLike, S, A> Expr_<Label, S, A> { map_shallow(self, map_expr, map_note, map_embed, map_label) } - pub fn map_embed<B, F>(&self, map_embed: &F) -> Expr_<Label, S, B> + pub fn map_embed<B, F>(&self, map_embed: &F) -> Expr<Label, S, B> where A: Clone, S: Clone, F: Fn(&A) -> B, { - let recurse = |e: &Expr_<Label, S, A>| -> Expr_<Label, S, B> { + let recurse = |e: &Expr<Label, S, A>| -> Expr<Label, S, B> { e.map_embed(map_embed) }; self.map_shallow(recurse, |x| x.clone(), map_embed, |x| x.clone()) @@ -338,30 +337,30 @@ impl<Label: StringLike, S, A> Expr_<Label, S, A> { pub fn bool_lit(&self) -> Option<bool> { match *self { - Expr_::BoolLit(v) => Some(v), + Expr::BoolLit(v) => Some(v), _ => None, } } pub fn natural_lit(&self) -> Option<usize> { match *self { - Expr_::NaturalLit(v) => Some(v), + Expr::NaturalLit(v) => Some(v), _ => None, } } pub fn text_lit(&self) -> Option<String> { match *self { - Expr_::TextLit(ref t) => Some(t.clone()), // FIXME? + Expr::TextLit(ref t) => Some(t.clone()), // FIXME? _ => None, } } } -impl<'i, S: Clone, A: Clone> Expr_<&'i str, S, A> { - pub fn take_ownership_of_labels<L: StringLike + From<String>>(&self) -> Expr_<L, S, A> { +impl<'i, S: Clone, A: Clone> Expr<&'i str, S, A> { + pub fn take_ownership_of_labels<L: StringLike + From<String>>(&self) -> Expr<L, S, A> { let recurse = - |e: &Expr_<&'i str, S, A>| -> Expr_<L, S, A> { e.take_ownership_of_labels() }; + |e: &Expr<&'i str, S, A>| -> Expr<L, S, A> { e.take_ownership_of_labels() }; map_shallow(self, recurse, |x| x.clone(), |x| x.clone(), |x: &&str| -> L { (*x).to_owned().into() }) } } @@ -376,10 +375,10 @@ impl<'i, S: Clone, A: Clone> Expr_<&'i str, S, A> { // you add a new constructor to the syntax tree without adding a matching // case the corresponding builder. -impl<Label: Display, S, A: Display> Display for Expr_<Label, S, A> { +impl<Label: Display, S, A: Display> Display for Expr<Label, S, A> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { // buildExprA - use crate::Expr_::*; + use crate::Expr::*; match self { &Annot(ref a, ref b) => { a.fmt_b(f)?; @@ -392,9 +391,9 @@ impl<Label: Display, S, A: Display> Display for Expr_<Label, S, A> { } } -impl<Label: Display, S, A: Display> Expr_<Label, S, A> { +impl<Label: Display, S, A: Display> Expr<Label, S, A> { fn fmt_b(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use crate::Expr_::*; + use crate::Expr::*; match self { &Lam(ref a, ref b, ref c) => { write!(f, "λ({} : ", a)?; @@ -479,7 +478,7 @@ impl<Label: Display, S, A: Display> Expr_<Label, S, A> { fn fmt_c(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use crate::BinOp::*; - use crate::Expr_::*; + use crate::Expr::*; match self { // FIXME precedence &BinOp(BoolOr, ref a, ref b) => { @@ -528,7 +527,7 @@ impl<Label: Display, S, A: Display> Expr_<Label, S, A> { } fn fmt_d(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use crate::Expr_::*; + use crate::Expr::*; match self { &App(ref a, ref b) => { a.fmt_d(f)?; @@ -541,7 +540,7 @@ impl<Label: Display, S, A: Display> Expr_<Label, S, A> { } fn fmt_e(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use crate::Expr_::*; + use crate::Expr::*; match self { &Field(ref a, ref b) => { a.fmt_e(f)?; @@ -553,7 +552,7 @@ impl<Label: Display, S, A: Display> Expr_<Label, S, A> { } fn fmt_f(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - use crate::Expr_::*; + use crate::Expr::*; match &self { &Var(a) => a.fmt(f), &Const(k) => k.fmt(f), @@ -703,21 +702,21 @@ pub fn pi<Label, S, A, Name, Et, Ev>( var: Name, ty: Et, value: Ev, -) -> Expr_<Label, S, A> +) -> Expr<Label, S, A> where Name: Into<Label>, - Et: Into<Expr_<Label, S, A>>, - Ev: Into<Expr_<Label, S, A>>, + Et: Into<Expr<Label, S, A>>, + Ev: Into<Expr<Label, S, A>>, { - Expr_::Pi(var.into(), bx(ty.into()), bx(value.into())) + Expr::Pi(var.into(), bx(ty.into()), bx(value.into())) } -pub fn app<Label, S, A, Ef, Ex>(f: Ef, x: Ex) -> Expr_<Label, S, A> +pub fn app<Label, S, A, Ef, Ex>(f: Ef, x: Ex) -> Expr<Label, S, A> where - Ef: Into<Expr_<Label, S, A>>, - Ex: Into<Expr_<Label, S, A>>, + Ef: Into<Expr<Label, S, A>>, + Ex: Into<Expr<Label, S, A>>, { - Expr_::App(bx(f.into()), bx(x.into())) + Expr::App(bx(f.into()), bx(x.into())) } pub type Builder = String; @@ -749,26 +748,26 @@ fn add_ui(u: usize, i: isize) -> usize { } pub fn map_shallow<Label1, Label2, S, T, A, B, F1, F2, F3, F4>( - e: &Expr_<Label1, S, A>, + e: &Expr<Label1, S, A>, map: F1, map_note: F2, map_embed: F3, map_label: F4, -) -> Expr_<Label2, T, B> +) -> Expr<Label2, T, B> where A: Clone, S: Clone, T: Clone, Label1: Display + fmt::Debug + Clone + Hash + Ord + Eq + Into<String> + Default, Label2: StringLike, - F1: Fn(&Expr_<Label1, S, A>) -> Expr_<Label2, T, B>, + F1: Fn(&Expr<Label1, S, A>) -> Expr<Label2, T, B>, F2: FnOnce(&S) -> T, F3: FnOnce(&A) -> B, F4: Fn(&Label1) -> Label2, { - use crate::Expr_::*; + use crate::Expr::*; let bxmap = - |x: &Expr_<Label1, S, A>| -> Box<Expr_<Label2, T, B>> { bx(map(x)) }; + |x: &Expr<Label1, S, A>| -> Box<Expr<Label2, T, B>> { bx(map(x)) }; let opt = |x| map_opt_box(x, &map); match *e { Const(k) => Const(k), @@ -930,12 +929,12 @@ where pub fn shift<Label, S, T, A: Clone>( d: isize, v: &V<Label>, - e: &Expr_<Label, S, A>, -) -> Expr_<Label, T, A> + e: &Expr<Label, S, A>, +) -> Expr<Label, T, A> where Label: StringLike, { - use crate::Expr_::*; + use crate::Expr::*; let V(x, n) = v; match e { Const(a) => Const(*a), @@ -1013,14 +1012,14 @@ fn shift_op2<Label, S, T, A, F>( f: F, d: isize, v: &V<Label>, - a: &Expr_<Label, S, A>, - b: &Expr_<Label, S, A>, -) -> Expr_<Label, T, A> + a: &Expr<Label, S, A>, + b: &Expr<Label, S, A>, +) -> Expr<Label, T, A> where F: FnOnce( - Box<Expr_<Label, T, A>>, - Box<Expr_<Label, T, A>>, - ) -> Expr_<Label, T, A>, + Box<Expr<Label, T, A>>, + Box<Expr<Label, T, A>>, + ) -> Expr<Label, T, A>, A: Clone, Label: StringLike, { @@ -1035,14 +1034,14 @@ where /// pub fn subst<Label: StringLike, S, T, A>( v: &V<Label>, - e: &Expr_<Label, S, A>, - b: &Expr_<Label, T, A>, -) -> Expr_<Label, S, A> + e: &Expr<Label, S, A>, + b: &Expr<Label, T, A>, +) -> Expr<Label, S, A> where S: Clone, A: Clone, { - use crate::Expr_::*; + use crate::Expr::*; let V(x, n) = v; match b { Const(a) => Const(*a), @@ -1122,15 +1121,15 @@ where fn subst_op2<Label: StringLike, S, T, A, F>( f: F, v: &V<Label>, - e: &Expr_<Label, S, A>, - a: &Expr_<Label, T, A>, - b: &Expr_<Label, T, A>, -) -> Expr_<Label, S, A> + e: &Expr<Label, S, A>, + a: &Expr<Label, T, A>, + b: &Expr<Label, T, A>, +) -> Expr<Label, S, A> where F: FnOnce( - Box<Expr_<Label, S, A>>, - Box<Expr_<Label, S, A>>, - ) -> Expr_<Label, S, A>, + Box<Expr<Label, S, A>>, + Box<Expr<Label, S, A>>, + ) -> Expr<Label, S, A>, S: Clone, A: Clone, { diff --git a/dhall_core/src/grammar_util.rs b/dhall_core/src/grammar_util.rs index 73f935f..2547e94 100644 --- a/dhall_core/src/grammar_util.rs +++ b/dhall_core/src/grammar_util.rs @@ -1,4 +1,4 @@ use crate::core::{Expr, Import, X}; -pub type ParsedExpr<'i> = Expr<'i, X, Import>; +pub type ParsedExpr<'i> = Expr<&'i str, X, Import>; pub type BoxExpr<'i> = Box<ParsedExpr<'i>>; diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs index d72b6bd..9d0a88b 100644 --- a/dhall_core/src/parser.rs +++ b/dhall_core/src/parser.rs @@ -539,7 +539,7 @@ rule!(import_raw<BoxExpr<'a>>; // TODO: handle "as Text" children!(import: import_hashed_raw) => { let (location, hash) = import; - bx(Expr_::Embed(Import { + bx(Expr::Embed(Import { mode: ImportMode::Code, hash, location, @@ -586,19 +586,19 @@ rule_group!(expression<BoxExpr<'a>>; rule!(lambda_expression<BoxExpr<'a>>; children!(label: str, typ: expression, body: expression) => { - bx(Expr_::Lam(label, typ, body)) + bx(Expr::Lam(label, typ, body)) } ); rule!(ifthenelse_expression<BoxExpr<'a>>; children!(cond: expression, left: expression, right: expression) => { - bx(Expr_::BoolIf(cond, left, right)) + bx(Expr::BoolIf(cond, left, right)) } ); rule!(let_expression<BoxExpr<'a>>; children!(bindings*: let_binding, final_expr: expression) => { - bindings.fold(final_expr, |acc, x| bx(Expr_::Let(x.0, x.1, x.2, acc))) + bindings.fold(final_expr, |acc, x| bx(Expr::Let(x.0, x.1, x.2, acc))) } ); @@ -608,27 +608,27 @@ rule!(let_binding<(&'a str, Option<BoxExpr<'a>>, BoxExpr<'a>)>; rule!(forall_expression<BoxExpr<'a>>; children!(label: str, typ: expression, body: expression) => { - bx(Expr_::Pi(label, typ, body)) + bx(Expr::Pi(label, typ, body)) } ); rule!(arrow_expression<BoxExpr<'a>>; children!(typ: expression, body: expression) => { - bx(Expr_::Pi("_", typ, body)) + bx(Expr::Pi("_", typ, body)) } ); rule!(merge_expression<BoxExpr<'a>>; children!(x: expression, y: expression, z?: expression) => { - bx(Expr_::Merge(x, y, z)) + bx(Expr::Merge(x, y, z)) } ); rule!(empty_collection<BoxExpr<'a>>; children!(x: str, y: expression) => { match x { - "Optional" => bx(Expr_::OptionalLit(Some(y), vec![])), - "List" => bx(Expr_::ListLit(Some(y), vec![])), + "Optional" => bx(Expr::OptionalLit(Some(y), vec![])), + "List" => bx(Expr::ListLit(Some(y), vec![])), _ => unreachable!(), } } @@ -636,7 +636,7 @@ rule!(empty_collection<BoxExpr<'a>>; rule!(non_empty_optional<BoxExpr<'a>>; children!(x: expression, _y: str, z: expression) => { - bx(Expr_::OptionalLit(Some(z), vec![*x])) + bx(Expr::OptionalLit(Some(z), vec![*x])) } ); @@ -644,7 +644,7 @@ macro_rules! binop { ($rule:ident, $op:ident) => { rule!($rule<BoxExpr<'a>>; children!(first: expression, rest*: expression) => { - rest.fold(first, |acc, e| bx(Expr_::BinOp(BinOp::$op, acc, e))) + rest.fold(first, |acc, e| bx(Expr::BinOp(BinOp::$op, acc, e))) } ); }; @@ -652,7 +652,7 @@ macro_rules! binop { rule!(annotated_expression<BoxExpr<'a>>; children!(e: expression, annot: expression) => { - bx(Expr_::Annot(e, annot)) + bx(Expr::Annot(e, annot)) }, children!(e: expression) => e, ); @@ -672,61 +672,61 @@ binop!(not_equal_expression, BoolNE); rule!(application_expression<BoxExpr<'a>>; children!(first: expression, rest*: expression) => { - rest.fold(first, |acc, e| bx(Expr_::App(acc, e))) + rest.fold(first, |acc, e| bx(Expr::App(acc, e))) } ); rule!(selector_expression_raw<BoxExpr<'a>>; children!(first: expression, rest*: str) => { - rest.fold(first, |acc, e| bx(Expr_::Field(acc, e))) + rest.fold(first, |acc, e| bx(Expr::Field(acc, e))) } ); rule!(literal_expression_raw<BoxExpr<'a>>; - children!(n: double_literal_raw) => bx(Expr_::DoubleLit(n)), - children!(n: minus_infinity_literal) => bx(Expr_::DoubleLit(std::f64::NEG_INFINITY)), - children!(n: plus_infinity_literal) => bx(Expr_::DoubleLit(std::f64::INFINITY)), - children!(n: NaN_raw) => bx(Expr_::DoubleLit(std::f64::NAN)), - children!(n: natural_literal_raw) => bx(Expr_::NaturalLit(n)), - children!(n: integer_literal_raw) => bx(Expr_::IntegerLit(n)), - children!(s: double_quote_literal) => bx(Expr_::TextLit(s)), - children!(s: single_quote_literal) => bx(Expr_::TextLit(s)), + children!(n: double_literal_raw) => bx(Expr::DoubleLit(n)), + children!(n: minus_infinity_literal) => bx(Expr::DoubleLit(std::f64::NEG_INFINITY)), + children!(n: plus_infinity_literal) => bx(Expr::DoubleLit(std::f64::INFINITY)), + children!(n: NaN_raw) => bx(Expr::DoubleLit(std::f64::NAN)), + children!(n: natural_literal_raw) => bx(Expr::NaturalLit(n)), + children!(n: integer_literal_raw) => bx(Expr::IntegerLit(n)), + children!(s: double_quote_literal) => bx(Expr::TextLit(s)), + children!(s: single_quote_literal) => bx(Expr::TextLit(s)), children!(e: expression) => e, ); rule!(identifier_raw<BoxExpr<'a>>; children!(name: str, idx?: natural_literal_raw) => { match Builtin::parse(name) { - Some(b) => bx(Expr_::Builtin(b)), + Some(b) => bx(Expr::Builtin(b)), None => match name { - "True" => bx(Expr_::BoolLit(true)), - "False" => bx(Expr_::BoolLit(false)), - "Type" => bx(Expr_::Const(Const::Type)), - "Kind" => bx(Expr_::Const(Const::Kind)), - name => bx(Expr_::Var(V(name, idx.unwrap_or(0)))), + "True" => bx(Expr::BoolLit(true)), + "False" => bx(Expr::BoolLit(false)), + "Type" => bx(Expr::Const(Const::Type)), + "Kind" => bx(Expr::Const(Const::Kind)), + name => bx(Expr::Var(V(name, idx.unwrap_or(0)))), } } } ); rule!(empty_record_literal<BoxExpr<'a>>; - children!() => bx(Expr_::RecordLit(BTreeMap::new())) + children!() => bx(Expr::RecordLit(BTreeMap::new())) ); rule!(empty_record_type<BoxExpr<'a>>; - children!() => bx(Expr_::Record(BTreeMap::new())) + children!() => bx(Expr::Record(BTreeMap::new())) ); rule!(non_empty_record_type_or_literal<BoxExpr<'a>>; children!(first_label: str, rest: non_empty_record_type) => { let (first_expr, mut map) = rest; map.insert(first_label, *first_expr); - bx(Expr_::Record(map)) + bx(Expr::Record(map)) }, children!(first_label: str, rest: non_empty_record_literal) => { let (first_expr, mut map) = rest; map.insert(first_label, *first_expr); - bx(Expr_::RecordLit(map)) + bx(Expr::RecordLit(map)) }, ); @@ -754,12 +754,12 @@ rule!(non_empty_record_literal<(BoxExpr<'a>, BTreeMap<&'a str, ParsedExpr<'a>>)> rule!(union_type_or_literal<BoxExpr<'a>>; children!(_e: empty_union_type) => { - bx(Expr_::Union(BTreeMap::new())) + bx(Expr::Union(BTreeMap::new())) }, children!(x: non_empty_union_type_or_literal) => { match x { - (Some((l, e)), entries) => bx(Expr_::UnionLit(l, e, entries)), - (None, entries) => bx(Expr_::Union(entries)), + (Some((l, e)), entries) => bx(Expr::UnionLit(l, e, entries)), + (None, entries) => bx(Expr::Union(entries)), } }, ); @@ -799,7 +799,7 @@ rule!(union_type_entry<(&'a str, BoxExpr<'a>)>; rule!(non_empty_list_literal_raw<BoxExpr<'a>>; children!(items*: expression) => { - bx(Expr_::ListLit(None, items.map(|x| *x).collect())) + bx(Expr::ListLit(None, items.map(|x| *x).collect())) } ); @@ -811,13 +811,13 @@ pub fn parse_expr<'i>(s: &'i str) -> ParseResult<BoxExpr<'i>> { let pairs = DhallParser::parse(Rule::final_expression, s)?; // Match the only item in the pairs iterator match_iter!(@panic; pairs; (p) => expression(p)) - // Ok(bx(Expr_::BoolLit(false))) + // Ok(bx(Expr::BoolLit(false))) } #[test] fn test_parse() { use crate::core::BinOp::*; - use crate::core::Expr_::*; + use crate::core::Expr::*; // let expr = r#"{ x = "foo", y = 4 }.x"#; // let expr = r#"(1 + 2) * 3"#; let expr = r#"if True then 1 + 3 * 5 else 2"#; |