diff options
Diffstat (limited to 'dhall_syntax/src')
-rw-r--r-- | dhall_syntax/src/core/import.rs | 9 | ||||
-rw-r--r-- | dhall_syntax/src/parser.rs | 12 | ||||
-rw-r--r-- | dhall_syntax/src/printer.rs | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/dhall_syntax/src/core/import.rs b/dhall_syntax/src/core/import.rs index 43597df..da3e99b 100644 --- a/dhall_syntax/src/core/import.rs +++ b/dhall_syntax/src/core/import.rs @@ -11,10 +11,15 @@ pub enum FilePrefix { Home, } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct FilePath { + pub file_path: Vec<String>, +} + /// The location of import (i.e. local vs. remote vs. environment) #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ImportLocation<SubExpr> { - Local(FilePrefix, Vec<String>), + Local(FilePrefix, FilePath), Remote(URL<SubExpr>), Env(String), Missing, @@ -24,7 +29,7 @@ pub enum ImportLocation<SubExpr> { pub struct URL<SubExpr> { pub scheme: Scheme, pub authority: String, - pub path: Vec<String>, + pub path: FilePath, pub query: Option<String>, pub headers: Option<SubExpr>, } diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 3f961e8..41d6d04 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -549,10 +549,10 @@ impl Parsers { }) .collect()) } - fn path(input: ParseInput<Rule>) -> ParseResult<Vec<String>> { + fn path(input: ParseInput<Rule>) -> ParseResult<FilePath> { Ok(parse_children!(input; [path_component(components)..] => { - components.collect() + FilePath { file_path: components.collect() } } )) } @@ -569,7 +569,7 @@ impl Parsers { #[alias(local_path)] fn parent_path( input: ParseInput<Rule>, - ) -> ParseResult<(FilePrefix, Vec<String>)> { + ) -> ParseResult<(FilePrefix, FilePath)> { Ok(parse_children!(input; [path(p)] => (FilePrefix::Parent, p) )) @@ -577,7 +577,7 @@ impl Parsers { #[alias(local_path)] fn here_path( input: ParseInput<Rule>, - ) -> ParseResult<(FilePrefix, Vec<String>)> { + ) -> ParseResult<(FilePrefix, FilePath)> { Ok(parse_children!(input; [path(p)] => (FilePrefix::Here, p) )) @@ -585,7 +585,7 @@ impl Parsers { #[alias(local_path)] fn home_path( input: ParseInput<Rule>, - ) -> ParseResult<(FilePrefix, Vec<String>)> { + ) -> ParseResult<(FilePrefix, FilePath)> { Ok(parse_children!(input; [path(p)] => (FilePrefix::Home, p) )) @@ -593,7 +593,7 @@ impl Parsers { #[alias(local_path)] fn absolute_path( input: ParseInput<Rule>, - ) -> ParseResult<(FilePrefix, Vec<String>)> { + ) -> ParseResult<(FilePrefix, FilePath)> { Ok(parse_children!(input; [path(p)] => (FilePrefix::Absolute, p) )) diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index f3dc648..1e3b7f2 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -378,12 +378,12 @@ impl<SubExpr: Display> Display for Import<SubExpr> { }; write!(f, "{}/", prefix)?; let path: String = - path.iter().map(|c| quote_if_needed(&*c)).join("/"); + path.file_path.iter().map(|c| quote_if_needed(&*c)).join("/"); f.write_str(&path)?; } Remote(url) => { write!(f, "{}://{}/", url.scheme, url.authority,)?; - let path: String = url.path.iter().join("/"); + let path: String = url.path.file_path.iter().join("/"); f.write_str(&path)?; if let Some(q) = &url.query { write!(f, "?{}", q)? |