From 6eb3612345c34e67acdc71662ea94f0952a48fd9 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 6 Dec 2020 17:47:32 +0000 Subject: An import location is not independent from the import mode --- dhall/src/semantics/parse.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'dhall/src/semantics/parse.rs') diff --git a/dhall/src/semantics/parse.rs b/dhall/src/semantics/parse.rs index fa7ba18..5870d47 100644 --- a/dhall/src/semantics/parse.rs +++ b/dhall/src/semantics/parse.rs @@ -2,47 +2,39 @@ use std::path::Path; use url::Url; use crate::error::Error; -use crate::semantics::resolve::{ - download_http_text, ImportLocation, ImportLocationKind, -}; -use crate::syntax::binary; -use crate::syntax::parse_expr; +use crate::semantics::resolve::{download_http_text, ImportLocation}; +use crate::syntax::{binary, parse_expr}; use crate::Parsed; pub fn parse_file(f: &Path) -> Result { let text = std::fs::read_to_string(f)?; let expr = parse_expr(&text)?; - let root_kind = ImportLocationKind::Local(f.to_owned()); - let root = ImportLocation { kind: root_kind }; + let root = ImportLocation::local_dhall_code(f.to_owned()); Ok(Parsed(expr, root)) } pub fn parse_remote(url: Url) -> Result { let body = download_http_text(url.clone())?; let expr = parse_expr(&body)?; - let root_kind = ImportLocationKind::Remote(url); - let root = ImportLocation { kind: root_kind }; + let root = ImportLocation::remote_dhall_code(url); Ok(Parsed(expr, root)) } pub fn parse_str(s: &str) -> Result { let expr = parse_expr(s)?; - let root_kind = ImportLocationKind::Missing; - let root = ImportLocation { kind: root_kind }; + let root = ImportLocation::dhall_code_of_unknown_origin(); Ok(Parsed(expr, root)) } pub fn parse_binary(data: &[u8]) -> Result { let expr = binary::decode(data)?; - let root_kind = ImportLocationKind::Missing; - let root = ImportLocation { kind: root_kind }; + let root = ImportLocation::dhall_code_of_unknown_origin(); Ok(Parsed(expr, root)) } pub fn parse_binary_file(f: &Path) -> Result { let data = crate::utils::read_binary_file(f)?; let expr = binary::decode(&data)?; - let root_kind = ImportLocationKind::Local(f.to_owned()); - let root = ImportLocation { kind: root_kind }; + let root = ImportLocation::local_dhall_code(f.to_owned()); Ok(Parsed(expr, root)) } -- cgit v1.2.3