summaryrefslogtreecommitdiff
path: root/dhall_syntax/src/parser.rs
diff options
context:
space:
mode:
authorFintan Halpenny2019-09-02 21:17:00 +0100
committerFintan Halpenny2019-09-02 21:17:00 +0100
commite73f822b6972e8fa2e72b56ff5378b91bea1a5e6 (patch)
tree853d36295b3a705d9143e0feb72855f900237de0 /dhall_syntax/src/parser.rs
parent4a86274878d5ab0ef4f9d8597606226adfd048de (diff)
Remove the notion of Directory and have File be the vector of components
Diffstat (limited to '')
-rw-r--r--dhall_syntax/src/parser.rs23
1 files changed, 6 insertions, 17 deletions
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<Rule>) -> String {
s
}
-fn to_file(path: Vec<String>) -> Result<File, String> {
- let mut path = path;
- let file_name: Option<String> = 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<URL>; 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 })
},
));