eyeprolog 1.2.16 → 1.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/repl.js +9 -2
- package/test/run-regression.mjs +42 -0
- package/the-art-of-eyeprolog.md +4 -2
package/package.json
CHANGED
package/src/repl.js
CHANGED
|
@@ -9,7 +9,7 @@ const ANSWER_HELP = `
|
|
|
9
9
|
SPACE, "n" or ";": next solution, if any
|
|
10
10
|
RETURN or ".": stop enumeration
|
|
11
11
|
"a": enumerate all solutions
|
|
12
|
-
"f": enumerate the next 5 solutions
|
|
12
|
+
"f": enumerate through the next group of 5 solutions
|
|
13
13
|
"h": display this help message
|
|
14
14
|
"w": write terms without depth limit
|
|
15
15
|
"p": print terms with depth limit
|
|
@@ -486,11 +486,13 @@ async function solveQuery(engine, state, goal, reader, output) {
|
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
let automatic = 0;
|
|
489
|
+
let answersShown = 0;
|
|
489
490
|
let firstAnswer = true;
|
|
490
491
|
while (!current.result.done) {
|
|
491
492
|
const next = pullSolution(solver, solutions, reader);
|
|
492
493
|
output.write(current.output);
|
|
493
494
|
output.write(`${firstAnswer ? ' ' : ''}${formatAnswer(engine, state, variables, current.result.value)}`);
|
|
495
|
+
answersShown++;
|
|
494
496
|
firstAnswer = false;
|
|
495
497
|
if (!next.error && next.result.done) {
|
|
496
498
|
output.write('.\n');
|
|
@@ -516,7 +518,12 @@ async function solveQuery(engine, state, goal, reader, output) {
|
|
|
516
518
|
break;
|
|
517
519
|
}
|
|
518
520
|
if (control === 'f') {
|
|
519
|
-
|
|
521
|
+
// `f` groups leaf answers in blocks of five, rather than merely
|
|
522
|
+
// adding five more answers after whatever the user has already
|
|
523
|
+
// inspected. Stop for control again at the next 5-answer boundary.
|
|
524
|
+
const remainder = answersShown % 5;
|
|
525
|
+
const answersToBoundary = remainder === 0 ? 5 : 5 - remainder;
|
|
526
|
+
automatic = answersToBoundary - 1;
|
|
520
527
|
break;
|
|
521
528
|
}
|
|
522
529
|
if (control === 'w' || control === 'p') {
|
package/test/run-regression.mjs
CHANGED
|
@@ -752,6 +752,48 @@ c4 ?- call((!;1)).
|
|
|
752
752
|
assertEqual(result.stderr, '', 'stderr');
|
|
753
753
|
},
|
|
754
754
|
},
|
|
755
|
+
{
|
|
756
|
+
name: 'REPL f stops at five-answer boundaries instead of adding five answers',
|
|
757
|
+
run: () => {
|
|
758
|
+
const result = runCli([], {
|
|
759
|
+
input:
|
|
760
|
+
'use_module(library(prologue), [between/3]).\n' +
|
|
761
|
+
'between(0,11,I).\nf\n\n' +
|
|
762
|
+
'between(0,11,J).\n;\n;\nf\n\n' +
|
|
763
|
+
'between(0,11,K).\nf\nf\n\n' +
|
|
764
|
+
'halt.\n',
|
|
765
|
+
});
|
|
766
|
+
assertEqual(result.status, 0, 'exit status');
|
|
767
|
+
assertEqual(result.stdout,
|
|
768
|
+
'?- true.\n' +
|
|
769
|
+
'?- I = 0\n' +
|
|
770
|
+
'; I = 1\n' +
|
|
771
|
+
'; I = 2\n' +
|
|
772
|
+
'; I = 3\n' +
|
|
773
|
+
'; I = 4\n' +
|
|
774
|
+
'; ... .\n' +
|
|
775
|
+
'?- J = 0\n' +
|
|
776
|
+
'; J = 1\n' +
|
|
777
|
+
'; J = 2\n' +
|
|
778
|
+
'; J = 3\n' +
|
|
779
|
+
'; J = 4\n' +
|
|
780
|
+
'; ... .\n' +
|
|
781
|
+
'?- K = 0\n' +
|
|
782
|
+
'; K = 1\n' +
|
|
783
|
+
'; K = 2\n' +
|
|
784
|
+
'; K = 3\n' +
|
|
785
|
+
'; K = 4\n' +
|
|
786
|
+
'; K = 5\n' +
|
|
787
|
+
'; K = 6\n' +
|
|
788
|
+
'; K = 7\n' +
|
|
789
|
+
'; K = 8\n' +
|
|
790
|
+
'; K = 9\n' +
|
|
791
|
+
'; ... .\n' +
|
|
792
|
+
'?- ',
|
|
793
|
+
'stdout');
|
|
794
|
+
assertEqual(result.stderr, '', 'stderr');
|
|
795
|
+
},
|
|
796
|
+
},
|
|
755
797
|
{
|
|
756
798
|
name: 'REPL parenthesizes operator-valued answer substitutions',
|
|
757
799
|
run: () => {
|
package/the-art-of-eyeprolog.md
CHANGED
|
@@ -6264,8 +6264,10 @@ may span lines and end with a full stop, as in Scryer Prolog:
|
|
|
6264
6264
|
|
|
6265
6265
|
When another answer exists in an interactive terminal, press `;`, Space, or
|
|
6266
6266
|
`n` to ask for it immediately; no Return is needed. Return or `.` stops
|
|
6267
|
-
enumeration, `a` enumerates all remaining answers, `f`
|
|
6268
|
-
five
|
|
6267
|
+
enumeration, `a` enumerates all remaining answers, and `f` advances to the
|
|
6268
|
+
next five-answer boundary (5, 10, 15, ... displayed leaf answers), regardless
|
|
6269
|
+
of how many answers were stepped through individually beforehand. `h` displays
|
|
6270
|
+
the answer-control help. While a query is actively
|
|
6269
6271
|
computing, EyeProlog releases readline's terminal signal handling: `Ctrl-C`
|
|
6270
6272
|
therefore terminates the current EyeProlog process immediately, and on POSIX
|
|
6271
6273
|
terminals `Ctrl-Z` suspends it in the usual shell-managed way. This remains a
|