diff options
author | Nadrieril Feneanar | 2019-08-14 00:09:14 +0200 |
---|---|---|
committer | GitHub | 2019-08-14 00:09:14 +0200 |
commit | 160b05778808976ab9bd79fa7a142ca2e94ac67a (patch) | |
tree | b3094a3d4e6b463724302b9be7e803a80ce4eed3 /dhall_syntax/src/parser.rs | |
parent | 5895c3aa6552f75d7e5202be561f9734fe8945e7 (diff) | |
parent | 66260f8e386f7a447352bd8ccbda064b00b698bc (diff) |
Merge pull request #102 from Nadrieril/inline-headers
Implement inline headers parsing
Diffstat (limited to '')
-rw-r--r-- | dhall_syntax/src/parser.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 1ab6e6d..8ecd0ab 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<Import>; -pub(crate) type ParsedSubExpr = SubExpr<Import>; -type ParsedText = InterpolatedText<SubExpr<Import>>; -type ParsedTextContents = InterpolatedTextContents<SubExpr<Import>>; +pub(crate) type ParsedExpr = Expr<Void>; +pub(crate) type ParsedSubExpr = SubExpr<Void>; +type ParsedText = InterpolatedText<ParsedSubExpr>; +type ParsedTextContents = InterpolatedTextContents<ParsedSubExpr>; pub type ParseError = pest::error::Error<Rule>; @@ -598,7 +598,7 @@ make_parser! { _ => unreachable!(), }); - rule!(http_raw<URL>; children!( + rule!(http_raw<URL<ParsedSubExpr>>; children!( [scheme(sch), authority(auth), path(p)] => URL { scheme: sch, authority: auth, @@ -619,10 +619,10 @@ make_parser! { rule!(query<String>; captured_str!(s) => s.to_owned()); - rule!(http<URL>; children!( + rule!(http<URL<ParsedSubExpr>>; 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<String>; children!( @@ -654,7 +654,7 @@ make_parser! { token_rule!(missing<()>); - rule!(import_type<ImportLocation>; children!( + rule!(import_type<ImportLocation<ParsedSubExpr>>; children!( [missing(_)] => { ImportLocation::Missing }, @@ -679,33 +679,33 @@ make_parser! { Hash::SHA256(hex::decode(hash).unwrap()) }); - rule!(import_hashed<ImportHashed>; children!( + rule!(import_hashed<crate::Import<ParsedSubExpr>>; 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<ParsedSubExpr> as expression; span; children!( - [import_hashed(location_hashed)] => { - spanned(span, Embed(Import { + [import_hashed(imp)] => { + spanned(span, Import(crate::Import { mode: ImportMode::Code, - location_hashed + ..imp })) }, - [import_hashed(location_hashed), Text(_)] => { - spanned(span, Embed(Import { + [import_hashed(imp), Text(_)] => { + spanned(span, Import(crate::Import { mode: ImportMode::RawText, - location_hashed + ..imp })) }, - [import_hashed(location_hashed), Location(_)] => { - spanned(span, Embed(Import { + [import_hashed(imp), Location(_)] => { + spanned(span, Import(crate::Import { mode: ImportMode::Location, - location_hashed + ..imp })) }, )); |