summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-04-10 19:17:34 +0200
committerNadrieril2019-04-10 19:17:34 +0200
commit58f10a2a274fe858da6cc73d4a33718bfc46d52b (patch)
treefb66688a951d1bb0ddedb975e5d9ebce0f86cb75 /dhall
parente1a30c6f248c0c17c97598290a0d94993dbb0325 (diff)
s/load_from/parse/
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/imports.rs8
-rw-r--r--dhall/src/main.rs2
-rw-r--r--dhall/src/tests.rs30
3 files changed, 20 insertions, 20 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index fdde8c3..a65be4f 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -90,7 +90,7 @@ fn resolve_expr(
}
impl Parsed {
- pub fn load_from_file(f: &Path) -> Result<Parsed, ImportError> {
+ pub fn parse_file(f: &Path) -> Result<Parsed, ImportError> {
let mut buffer = String::new();
File::open(f)?.read_to_string(&mut buffer)?;
let expr = parse_expr(&*buffer)?;
@@ -98,13 +98,13 @@ impl Parsed {
Ok(Parsed(expr, root))
}
- pub fn load_from_str(s: &str) -> Result<Parsed, ImportError> {
+ pub fn parse_str(s: &str) -> Result<Parsed, ImportError> {
let expr = parse_expr(s)?;
let root = ImportRoot::LocalDir(std::env::current_dir()?);
Ok(Parsed(expr, root))
}
- pub fn load_from_binary_file(f: &Path) -> Result<Parsed, ImportError> {
+ pub fn parse_binary_file(f: &Path) -> Result<Parsed, ImportError> {
let mut buffer = Vec::new();
File::open(f)?.read_to_end(&mut buffer)?;
let expr = crate::binary::decode(&buffer)?;
@@ -125,7 +125,7 @@ pub fn load_dhall_file(
f: &Path,
resolve_imports: bool,
) -> Result<Expr<X, X>, ImportError> {
- let expr = Parsed::load_from_file(f)?;
+ let expr = Parsed::parse_file(f)?;
let expr = resolve_expr(expr, resolve_imports)?;
Ok(expr.0.unroll())
}
diff --git a/dhall/src/main.rs b/dhall/src/main.rs
index 2881d5a..3b61a44 100644
--- a/dhall/src/main.rs
+++ b/dhall/src/main.rs
@@ -55,7 +55,7 @@ fn main() {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer).unwrap();
- let expr = match dhall::expr::Parsed::load_from_str(&buffer) {
+ let expr = match dhall::expr::Parsed::parse_str(&buffer) {
Ok(expr) => expr,
Err(e) => {
print_error(&format!("Parse error {}", e), &buffer, 0, 0);
diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs
index ebb8855..737a8a4 100644
--- a/dhall/src/tests.rs
+++ b/dhall/src/tests.rs
@@ -51,16 +51,16 @@ fn read_dhall_file<'i>(file_path: &str) -> Result<Expr<X, X>, ImportError> {
crate::imports::load_dhall_file(&PathBuf::from(file_path), true)
}
-fn load_from_file_str<'i>(
+fn parse_file_str<'i>(
file_path: &str,
) -> Result<crate::expr::Parsed, ImportError> {
- crate::expr::Parsed::load_from_file(&PathBuf::from(file_path))
+ crate::expr::Parsed::parse_file(&PathBuf::from(file_path))
}
-fn load_from_binary_file_str<'i>(
+fn parse_binary_file_str<'i>(
file_path: &str,
) -> Result<crate::expr::Parsed, ImportError> {
- crate::expr::Parsed::load_from_binary_file(&PathBuf::from(file_path))
+ crate::expr::Parsed::parse_binary_file(&PathBuf::from(file_path))
}
pub fn run_test(base_path: &str, feature: Feature) {
@@ -80,24 +80,24 @@ pub fn run_test(base_path: &str, feature: Feature) {
ParserSuccess => {
let expr_file_path = base_path.clone() + "A.dhall";
let expected_file_path = base_path + "B.dhallb";
- let expr = load_from_file_str(&expr_file_path)
+ let expr = parse_file_str(&expr_file_path)
.map_err(|e| println!("{}", e))
.unwrap();
- let expected = load_from_binary_file_str(&expected_file_path)
+ let expected = parse_binary_file_str(&expected_file_path)
.map_err(|e| println!("{}", e))
.unwrap();
assert_eq_pretty!(expr, expected);
// Round-trip pretty-printer
- let expr =
- crate::expr::Parsed::load_from_str(&expr.to_string()).unwrap();
+ let expr: crate::expr::Parsed =
+ crate::from_str(&expr.to_string(), None).unwrap();
assert_eq!(expr, expected);
}
ParserFailure => {
let file_path = base_path + ".dhall";
- let err = load_from_file_str(&file_path).unwrap_err();
+ let err = parse_file_str(&file_path).unwrap_err();
match err {
ImportError::ParseError(_) => {}
e => panic!("Expected parse error, got: {:?}", e),
@@ -106,13 +106,13 @@ pub fn run_test(base_path: &str, feature: Feature) {
Normalization => {
let expr_file_path = base_path.clone() + "A.dhall";
let expected_file_path = base_path + "B.dhall";
- let expr = load_from_file_str(&expr_file_path)
+ let expr = parse_file_str(&expr_file_path)
.unwrap()
.resolve()
.unwrap()
.skip_typecheck()
.normalize();
- let expected = load_from_file_str(&expected_file_path)
+ let expected = parse_file_str(&expected_file_path)
.unwrap()
.resolve()
.unwrap()
@@ -123,7 +123,7 @@ pub fn run_test(base_path: &str, feature: Feature) {
}
TypecheckFailure => {
let file_path = base_path + ".dhall";
- load_from_file_str(&file_path)
+ parse_file_str(&file_path)
.unwrap()
.skip_resolve()
.unwrap()
@@ -149,7 +149,7 @@ pub fn run_test(base_path: &str, feature: Feature) {
}
TypeInferenceFailure => {
let file_path = base_path + ".dhall";
- load_from_file_str(&file_path)
+ parse_file_str(&file_path)
.unwrap()
.skip_resolve()
.unwrap()
@@ -159,14 +159,14 @@ pub fn run_test(base_path: &str, feature: Feature) {
TypeInferenceSuccess => {
let expr_file_path = base_path.clone() + "A.dhall";
let expected_file_path = base_path + "B.dhall";
- let expr = load_from_file_str(&expr_file_path)
+ let expr = parse_file_str(&expr_file_path)
.unwrap()
.skip_resolve()
.unwrap()
.typecheck()
.unwrap();
let ty = expr.get_type().as_normalized().unwrap();
- let expected = load_from_file_str(&expected_file_path)
+ let expected = parse_file_str(&expected_file_path)
.unwrap()
.skip_resolve()
.unwrap()