From 8d45d633dfa60e8d64c9e6e742de4e33496bf0fa Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 13 Aug 2019 22:11:45 +0200 Subject: Store Imports in their own node instead of in Embed --- dhall_syntax/src/parser.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dhall_syntax/src/parser.rs') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 1ab6e6d..a8dd359 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -15,10 +15,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. -pub(crate) type ParsedExpr = Expr; -pub(crate) type ParsedSubExpr = SubExpr; -type ParsedText = InterpolatedText>; -type ParsedTextContents = InterpolatedTextContents>; +pub(crate) type ParsedExpr = Expr; +pub(crate) type ParsedSubExpr = SubExpr; +type ParsedText = InterpolatedText; +type ParsedTextContents = InterpolatedTextContents; pub type ParseError = pest::error::Error; @@ -691,19 +691,19 @@ make_parser! { rule!(import as expression; span; children!( [import_hashed(location_hashed)] => { - spanned(span, Embed(Import { + spanned(span, Import(crate::Import { mode: ImportMode::Code, location_hashed })) }, [import_hashed(location_hashed), Text(_)] => { - spanned(span, Embed(Import { + spanned(span, Import(crate::Import { mode: ImportMode::RawText, location_hashed })) }, [import_hashed(location_hashed), Location(_)] => { - spanned(span, Embed(Import { + spanned(span, Import(crate::Import { mode: ImportMode::Location, location_hashed })) -- cgit v1.2.3 From 66260f8e386f7a447352bd8ccbda064b00b698bc Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 13 Aug 2019 23:44:52 +0200 Subject: Implement inline headers parsing --- dhall_syntax/src/parser.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'dhall_syntax/src/parser.rs') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index a8dd359..8ecd0ab 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -598,7 +598,7 @@ make_parser! { _ => unreachable!(), }); - rule!(http_raw; children!( + rule!(http_raw>; children!( [scheme(sch), authority(auth), path(p)] => URL { scheme: sch, authority: auth, @@ -619,10 +619,10 @@ make_parser! { rule!(query; captured_str!(s) => s.to_owned()); - rule!(http; children!( + rule!(http>; children!( [http_raw(url)] => url, - [http_raw(url), import_hashed(ih)] => - URL { headers: Some(Box::new(ih)), ..url }, + [http_raw(url), expression(e)] => + URL { headers: Some(e), ..url }, )); rule!(env; children!( @@ -654,7 +654,7 @@ make_parser! { token_rule!(missing<()>); - rule!(import_type; children!( + rule!(import_type>; children!( [missing(_)] => { ImportLocation::Missing }, @@ -679,33 +679,33 @@ make_parser! { Hash::SHA256(hex::decode(hash).unwrap()) }); - rule!(import_hashed; children!( + rule!(import_hashed>; children!( [import_type(location)] => - ImportHashed { location, hash: None }, + crate::Import {mode: ImportMode::Code, location, hash: None }, [import_type(location), hash(h)] => - ImportHashed { location, hash: Some(h) }, + crate::Import {mode: ImportMode::Code, location, hash: Some(h) }, )); token_rule!(Text<()>); token_rule!(Location<()>); rule!(import as expression; span; children!( - [import_hashed(location_hashed)] => { + [import_hashed(imp)] => { spanned(span, Import(crate::Import { mode: ImportMode::Code, - location_hashed + ..imp })) }, - [import_hashed(location_hashed), Text(_)] => { + [import_hashed(imp), Text(_)] => { spanned(span, Import(crate::Import { mode: ImportMode::RawText, - location_hashed + ..imp })) }, - [import_hashed(location_hashed), Location(_)] => { + [import_hashed(imp), Location(_)] => { spanned(span, Import(crate::Import { mode: ImportMode::Location, - location_hashed + ..imp })) }, )); -- cgit v1.2.3