From e73f822b6972e8fa2e72b56ff5378b91bea1a5e6 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 2 Sep 2019 21:17:00 +0100 Subject: Remove the notion of Directory and have File be the vector of components --- dhall_syntax/src/parser.rs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'dhall_syntax/src/parser.rs') diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index a2495ee..71d0936 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -147,14 +147,6 @@ fn debug_pair(pair: Pair) -> String { s } -fn to_file(path: Vec) -> Result { - let mut path = path; - let file_name: Option = path.pop(); - let file = file_name.ok_or("Empty file path was provided")?; - let directory = Directory { components: path }; - Ok(File { directory: directory, file: file }) -} - macro_rules! make_parser { (@pattern, rule, $name:ident) => (Rule::$name); (@pattern, token_rule, $name:ident) => (Rule::$name); @@ -638,22 +630,20 @@ make_parser! { }); rule!(http_raw; children!( - [scheme(sch), authority(auth), path(p)] => { - let file = to_file(p)?; + [scheme(sch), authority(auth), path(file_path)] => { URL { scheme: sch, authority: auth, - path: file, + path: File { file_path }, query: None, headers: None, } }, - [scheme(sch), authority(auth), path(p), query(q)] => { - let file = to_file(p)?; + [scheme(sch), authority(auth), path(file_path), query(q)] => { URL { scheme: sch, authority: auth, - path: file, + path: File { file_path }, query: Some(q), headers: None, } @@ -709,9 +699,8 @@ make_parser! { [http(url)] => { ImportLocation::Remote(url) }, - [local((prefix, p))] => { - let file = to_file(p)?; - ImportLocation::Local(prefix, file) + [local((prefix, file_path))] => { + ImportLocation::Local(prefix, File { file_path }) }, )); -- cgit v1.2.3