split into lib and bin

* makes most pub things in src/ pub(crate) as not to expose things accidentally
  * only those things needed by src/bin/scryer-prolog.rs and tests/scryer.rs
    should be pub
* split src/main.rs into src/lib.rs and src/bin/scryer-prolog.rs
* add tests folder and run most of the files in src/tests with cargo test
  added bytes method to Stream in src/machine/streams.rs to check if stdout is as expected
This commit is contained in:
Skgland
2021-02-25 23:24:20 +01:00
parent f935060b2b
commit 2f428b7261
35 changed files with 981 additions and 964 deletions

View File

@@ -30,7 +30,7 @@ pub(crate) enum CutContext {
HasCutVariable,
}
pub fn fold_by_str<I>(terms: I, mut term: Term, sym: ClauseName) -> Term
pub(crate) fn fold_by_str<I>(terms: I, mut term: Term, sym: ClauseName) -> Term
where
I: DoubleEndedIterator<Item = Term>,
{
@@ -46,7 +46,11 @@ where
term
}
pub fn to_op_decl(prec: usize, spec: &str, name: ClauseName) -> Result<OpDecl, CompilationError> {
pub(crate) fn to_op_decl(
prec: usize,
spec: &str,
name: ClauseName,
) -> Result<OpDecl, CompilationError> {
match spec {
"xfx" => Ok(OpDecl::new(prec, XFX, name)),
"xfy" => Ok(OpDecl::new(prec, XFY, name)),
@@ -825,11 +829,7 @@ impl Preprocessor {
cut_context: CutContext,
) -> Result<Rule, CompilationError> {
let post_head_terms: Vec<_> = terms.drain(1..).collect();
let mut query_terms = self.setup_query(
load_state,
post_head_terms,
cut_context,
)?;
let mut query_terms = self.setup_query(load_state, post_head_terms, cut_context)?;
let clauses = query_terms.drain(1..).collect();
let qt = query_terms.pop().unwrap();
@@ -894,11 +894,7 @@ impl Preprocessor {
let mut results = VecDeque::new();
for term in terms.into_iter() {
results.push_back(self.try_term_to_tl(
load_state,
term,
cut_context,
)?);
results.push_back(self.try_term_to_tl(load_state, term, cut_context)?);
}
Ok(results)