diff options
author | Nadrieril | 2019-05-04 17:59:05 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-04 17:59:05 +0200 |
commit | 4c159640e5ee77ffa48b85a5bffa56350cf933ef (patch) | |
tree | c0ff9231ed28538f4f1dc13d8e6347e3c14a06b5 /dhall_syntax/src/parser.rs | |
parent | 0e5c93c398645d39fceb98d054f1a7e67025b4fd (diff) |
Make SubExpr generic in the variable labels type
Diffstat (limited to 'dhall_syntax/src/parser.rs')
-rw-r--r-- | dhall_syntax/src/parser.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 83ccc1e..bdef553 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -8,7 +8,13 @@ use std::rc::Rc; use dhall_generated_parser::{DhallParser, Rule}; -use crate::ExprF::*; +use crate::ExprF::{ + Annot, App, BinOp, BoolIf, BoolLit, Builtin, Const, DoubleLit, Embed, + EmptyListLit, Field, IntegerLit, Lam, Let, Merge, NEListLit, NaturalLit, + OldOptionalLit, Pi, Projection, RecordLit, RecordType, SomeLit, TextLit, + UnionLit, UnionType, +}; + use crate::*; // This file consumes the parse tree generated by pest and turns it into @@ -16,10 +22,10 @@ use crate::*; // 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 ParsedExpr = Expr<Span, Import>; -type ParsedSubExpr = SubExpr<Span, Import>; -type ParsedText = InterpolatedText<SubExpr<Span, Import>>; -type ParsedTextContents = InterpolatedTextContents<SubExpr<Span, Import>>; +type ParsedExpr = Expr<Label, Span, Import>; +type ParsedSubExpr = SubExpr<Label, Span, Import>; +type ParsedText = InterpolatedText<ParsedSubExpr>; +type ParsedTextContents = InterpolatedTextContents<ParsedSubExpr>; pub type ParseError = pest::error::Error<Rule>; @@ -504,17 +510,17 @@ make_parser! { rule!(identifier<ParsedSubExpr> as expression; span; children!( [variable(v)] => { - spanned(span, Var(v)) + spanned(span, ExprF::Var(v)) }, [builtin(e)] => e, )); - rule!(variable<V<Label>>; children!( + rule!(variable<Var<Label>>; children!( [label(l), natural_literal(idx)] => { - V(l, idx) + Var(l, idx) }, [label(l)] => { - V(l, 0) + Var(l, 0) }, )); |