@tuprolog/2p-full 0.31.21 → 0.32.1
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/2p-bdd.js +198 -215
- package/2p-bdd.js.map +1 -1
- package/2p-core.js +3282 -5092
- package/2p-core.js.map +1 -1
- package/2p-full.js +6 -6
- package/2p-io-lib.js +874 -1121
- package/2p-io-lib.js.map +1 -1
- package/2p-oop-lib.js +1140 -1327
- package/2p-oop-lib.js.map +1 -1
- package/2p-parser-core.js +438 -609
- package/2p-parser-core.js.map +1 -1
- package/2p-parser-js.js +7 -8
- package/2p-parser-js.js.map +1 -1
- package/2p-parser-theory.js +35 -39
- package/2p-parser-theory.js.map +1 -1
- package/2p-repl.js +152 -179
- package/2p-repl.js.map +1 -1
- package/2p-solve-classic.js +1141 -1371
- package/2p-solve-classic.js.map +1 -1
- package/2p-solve-plp.js +9 -14
- package/2p-solve-plp.js.map +1 -1
- package/2p-solve-problog.js +1689 -1981
- package/2p-solve-problog.js.map +1 -1
- package/2p-solve-streams.js +1206 -1372
- package/2p-solve-streams.js.map +1 -1
- package/2p-solve.js +4879 -6147
- package/2p-solve.js.map +1 -1
- package/2p-theory.js +1820 -2246
- package/2p-theory.js.map +1 -1
- package/2p-unify.js +290 -330
- package/2p-unify.js.map +1 -1
- package/2p-utils.js +483 -557
- package/2p-utils.js.map +1 -1
- package/clikt-clikt-js-ir.js +2243 -3266
- package/clikt-clikt-js-ir.js.map +1 -1
- package/{kotlin-kotlin-stdlib-js-ir.js → kotlin-kotlin-stdlib.js} +9601 -10371
- package/kotlin-kotlin-stdlib.js.map +1 -0
- package/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.js +15 -0
- package/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.js.map +1 -0
- package/kt-math.js +2926 -4247
- package/kt-math.js.map +1 -1
- package/package.json +9 -3
- package/kotlin-kotlin-stdlib-js-ir.js.map +0 -1
package/2p-repl.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(function (root, factory) {
|
|
2
2
|
if (typeof define === 'function' && define.amd)
|
|
3
|
-
define(['exports', './
|
|
3
|
+
define(['exports', './kotlin-kotlin-stdlib.js', './2p-solve.js', './2p-core.js', './clikt-clikt-js-ir.js', './2p-theory.js', './2p-parser-core.js', './2p-io-lib.js', './2p-oop-lib.js'], factory);
|
|
4
4
|
else if (typeof exports === 'object')
|
|
5
|
-
factory(module.exports, require('./
|
|
5
|
+
factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./2p-solve.js'), require('./2p-core.js'), require('./clikt-clikt-js-ir.js'), require('./2p-theory.js'), require('./2p-parser-core.js'), require('./2p-io-lib.js'), require('./2p-oop-lib.js'));
|
|
6
6
|
else {
|
|
7
|
+
if (typeof this['kotlin-kotlin-stdlib'] === 'undefined') {
|
|
8
|
+
throw new Error("Error loading module '2p-repl'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to '2p-repl'.");
|
|
9
|
+
}
|
|
7
10
|
if (typeof this['2p-solve'] === 'undefined') {
|
|
8
11
|
throw new Error("Error loading module '2p-repl'. Its dependency '2p-solve' was not found. Please, check whether '2p-solve' is loaded prior to '2p-repl'.");
|
|
9
12
|
}
|
|
10
|
-
if (typeof this['kotlin-kotlin-stdlib-js-ir'] === 'undefined') {
|
|
11
|
-
throw new Error("Error loading module '2p-repl'. Its dependency 'kotlin-kotlin-stdlib-js-ir' was not found. Please, check whether 'kotlin-kotlin-stdlib-js-ir' is loaded prior to '2p-repl'.");
|
|
12
|
-
}
|
|
13
13
|
if (typeof this['2p-core'] === 'undefined') {
|
|
14
14
|
throw new Error("Error loading module '2p-repl'. Its dependency '2p-core' was not found. Please, check whether '2p-core' is loaded prior to '2p-repl'.");
|
|
15
15
|
}
|
|
@@ -28,68 +28,68 @@
|
|
|
28
28
|
if (typeof this['2p-oop-lib'] === 'undefined') {
|
|
29
29
|
throw new Error("Error loading module '2p-repl'. Its dependency '2p-oop-lib' was not found. Please, check whether '2p-oop-lib' is loaded prior to '2p-repl'.");
|
|
30
30
|
}
|
|
31
|
-
root['2p-repl'] = factory(typeof this['2p-repl'] === 'undefined' ? {} : this['2p-repl'], this['
|
|
31
|
+
root['2p-repl'] = factory(typeof this['2p-repl'] === 'undefined' ? {} : this['2p-repl'], this['kotlin-kotlin-stdlib'], this['2p-solve'], this['2p-core'], this['clikt-clikt-js-ir'], this['2p-theory'], this['2p-parser-core'], this['2p-io-lib'], this['2p-oop-lib']);
|
|
32
32
|
}
|
|
33
|
-
}(this, function (_,
|
|
33
|
+
}(this, function (_, kotlin_kotlin, kotlin_it_unibo_tuprolog_solve, kotlin_it_unibo_tuprolog_core, kotlin_clikt_clikt, kotlin_it_unibo_tuprolog_theory, kotlin_it_unibo_tuprolog_parser_core, kotlin_it_unibo_tuprolog_io_lib, kotlin_it_unibo_tuprolog_oop_lib) {
|
|
34
34
|
'use strict';
|
|
35
35
|
//region block: imports
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
36
|
+
var Unit_instance = kotlin_kotlin.$_$.y1;
|
|
37
|
+
var Halt = kotlin_it_unibo_tuprolog_solve.$_$.l4;
|
|
38
|
+
var isInterface = kotlin_kotlin.$_$.j6;
|
|
39
|
+
var No = kotlin_it_unibo_tuprolog_solve.$_$.m4;
|
|
40
|
+
var Yes = kotlin_it_unibo_tuprolog_solve.$_$.n4;
|
|
41
|
+
var Companion_instance = kotlin_it_unibo_tuprolog_solve.$_$.l2;
|
|
41
42
|
var format = kotlin_it_unibo_tuprolog_core.$_$.c3;
|
|
42
43
|
var ProgramResult = kotlin_clikt_clikt.$_$.b;
|
|
43
44
|
var HaltException = kotlin_it_unibo_tuprolog_solve.$_$.r2;
|
|
44
|
-
var StringBuilder = kotlin_kotlin.$_$.
|
|
45
|
-
var THROW_CCE = kotlin_kotlin.$_$.
|
|
46
|
-
var isCharSequence = kotlin_kotlin.$_$.
|
|
47
|
-
var trim = kotlin_kotlin.$_$.
|
|
48
|
-
var toString = kotlin_kotlin.$_$.
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var VOID = kotlin_kotlin.$_$.gc;
|
|
45
|
+
var StringBuilder = kotlin_kotlin.$_$.j9;
|
|
46
|
+
var THROW_CCE = kotlin_kotlin.$_$.vb;
|
|
47
|
+
var isCharSequence = kotlin_kotlin.$_$.h6;
|
|
48
|
+
var trim = kotlin_kotlin.$_$.fb;
|
|
49
|
+
var toString = kotlin_kotlin.$_$.z6;
|
|
50
|
+
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.k1;
|
|
51
|
+
var endsWith = kotlin_kotlin.$_$.p9;
|
|
52
|
+
var VOID = kotlin_kotlin.$_$.d;
|
|
53
53
|
var CliktCommand = kotlin_clikt_clikt.$_$.a;
|
|
54
|
-
var emptyMap = kotlin_kotlin.$_$.
|
|
55
|
-
var charSequenceLength = kotlin_kotlin.$_$.
|
|
56
|
-
var charSequenceGet = kotlin_kotlin.$_$.
|
|
57
|
-
var toString_0 = kotlin_kotlin.$_$.
|
|
58
|
-
var titlecase = kotlin_kotlin.$_$.
|
|
59
|
-
var isLowerCase = kotlin_kotlin.$_$.
|
|
60
|
-
var protoOf = kotlin_kotlin.$_$.
|
|
54
|
+
var emptyMap = kotlin_kotlin.$_$.a3;
|
|
55
|
+
var charSequenceLength = kotlin_kotlin.$_$.u5;
|
|
56
|
+
var charSequenceGet = kotlin_kotlin.$_$.t5;
|
|
57
|
+
var toString_0 = kotlin_kotlin.$_$.o1;
|
|
58
|
+
var titlecase = kotlin_kotlin.$_$.sa;
|
|
59
|
+
var isLowerCase = kotlin_kotlin.$_$.u9;
|
|
60
|
+
var protoOf = kotlin_kotlin.$_$.u6;
|
|
61
61
|
var defaultCliktConsole = kotlin_clikt_clikt.$_$.d;
|
|
62
|
-
var classMeta = kotlin_kotlin.$_$.
|
|
63
|
-
var setMetadataFor = kotlin_kotlin.$_$.
|
|
62
|
+
var classMeta = kotlin_kotlin.$_$.v5;
|
|
63
|
+
var setMetadataFor = kotlin_kotlin.$_$.v6;
|
|
64
64
|
var TuPrologException_init_$Init$ = kotlin_it_unibo_tuprolog_core.$_$.m;
|
|
65
|
-
var objectCreate = kotlin_kotlin.$_$.
|
|
66
|
-
var captureStack = kotlin_kotlin.$_$.
|
|
65
|
+
var objectCreate = kotlin_kotlin.$_$.s6;
|
|
66
|
+
var captureStack = kotlin_kotlin.$_$.q5;
|
|
67
67
|
var TuPrologException = kotlin_it_unibo_tuprolog_core.$_$.l1;
|
|
68
|
-
var objectMeta = kotlin_kotlin.$_$.
|
|
69
|
-
var
|
|
70
|
-
var trimMargin = kotlin_kotlin.$_$.
|
|
68
|
+
var objectMeta = kotlin_kotlin.$_$.t6;
|
|
69
|
+
var Companion_instance_0 = kotlin_it_unibo_tuprolog_theory.$_$.b;
|
|
70
|
+
var trimMargin = kotlin_kotlin.$_$.db;
|
|
71
71
|
var ParseException = kotlin_it_unibo_tuprolog_parser_core.$_$.b;
|
|
72
|
-
var
|
|
72
|
+
var Companion_getInstance = kotlin_it_unibo_tuprolog_core.$_$.d1;
|
|
73
73
|
var parseStructWithOperators = kotlin_it_unibo_tuprolog_parser_core.$_$.e;
|
|
74
|
-
var
|
|
75
|
-
var joinToString = kotlin_kotlin.$_$.
|
|
74
|
+
var Companion_instance_1 = kotlin_it_unibo_tuprolog_core.$_$.f1;
|
|
75
|
+
var joinToString = kotlin_kotlin.$_$.i3;
|
|
76
76
|
var option = kotlin_clikt_clikt.$_$.i;
|
|
77
77
|
var multiple = kotlin_clikt_clikt.$_$.h;
|
|
78
78
|
var int = kotlin_clikt_clikt.$_$.j;
|
|
79
79
|
var default_0 = kotlin_clikt_clikt.$_$.f;
|
|
80
80
|
var flag = kotlin_clikt_clikt.$_$.g;
|
|
81
|
-
var toLong = kotlin_kotlin.$_$.
|
|
81
|
+
var toLong = kotlin_kotlin.$_$.x6;
|
|
82
82
|
var Info_getInstance = kotlin_it_unibo_tuprolog_core.$_$.k1;
|
|
83
|
-
var
|
|
84
|
-
var
|
|
83
|
+
var Companion_instance_2 = kotlin_it_unibo_tuprolog_solve.$_$.l1;
|
|
84
|
+
var Companion_instance_3 = kotlin_it_unibo_tuprolog_solve.$_$.d2;
|
|
85
85
|
var IOLib_getInstance = kotlin_it_unibo_tuprolog_io_lib.$_$.a;
|
|
86
86
|
var arrayConcat = kotlin_kotlin.$_$.a;
|
|
87
87
|
var OOPLib_getInstance = kotlin_it_unibo_tuprolog_oop_lib.$_$.a;
|
|
88
|
-
var
|
|
88
|
+
var Companion_getInstance_0 = kotlin_it_unibo_tuprolog_solve.$_$.n2;
|
|
89
89
|
var TrackVariables_getInstance = kotlin_it_unibo_tuprolog_solve.$_$.a2;
|
|
90
|
-
var KProperty1 = kotlin_kotlin.$_$.
|
|
91
|
-
var getPropertyCallableRef = kotlin_kotlin.$_$.
|
|
92
|
-
var NotImplementedError = kotlin_kotlin.$_$.
|
|
90
|
+
var KProperty1 = kotlin_kotlin.$_$.q7;
|
|
91
|
+
var getPropertyCallableRef = kotlin_kotlin.$_$.c6;
|
|
92
|
+
var NotImplementedError = kotlin_kotlin.$_$.qb;
|
|
93
93
|
var parseStruct = kotlin_it_unibo_tuprolog_parser_core.$_$.d;
|
|
94
94
|
var argument = kotlin_clikt_clikt.$_$.e;
|
|
95
95
|
var subcommands = kotlin_clikt_clikt.$_$.c;
|
|
@@ -99,32 +99,31 @@
|
|
|
99
99
|
setMetadataFor(NullInputException, 'NullInputException', classMeta, TuPrologException);
|
|
100
100
|
setMetadataFor(Companion, 'Companion', objectMeta);
|
|
101
101
|
setMetadataFor(TuPrologCmd, 'TuPrologCmd', classMeta, AbstractTuPrologCommand);
|
|
102
|
-
setMetadataFor(TuPrologSolveQuery, 'TuPrologSolveQuery', classMeta, AbstractTuPrologCommand);
|
|
102
|
+
setMetadataFor(TuPrologSolveQuery, 'TuPrologSolveQuery', classMeta, AbstractTuPrologCommand, VOID, TuPrologSolveQuery);
|
|
103
103
|
//endregion
|
|
104
104
|
function printSolution($this, sol, operatorSet) {
|
|
105
|
-
|
|
106
|
-
if (isInterface(tmp0_subject, Yes)) {
|
|
105
|
+
if (isInterface(sol, Yes)) {
|
|
107
106
|
printYesSolution($this, sol, operatorSet);
|
|
108
107
|
} else {
|
|
109
|
-
if (isInterface(
|
|
108
|
+
if (isInterface(sol, No)) {
|
|
110
109
|
printNoSolution($this, sol, operatorSet);
|
|
111
110
|
} else {
|
|
112
|
-
if (isInterface(
|
|
111
|
+
if (isInterface(sol, Halt)) {
|
|
113
112
|
printHaltSolution($this, sol, operatorSet);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
function printYesSolution($this, sol, operatorSet) {
|
|
119
|
-
$this.
|
|
118
|
+
$this.d3x(format(sol, Companion_instance.withOperators(operatorSet)));
|
|
120
119
|
}
|
|
121
120
|
function printHaltSolution($this, sol, operatorSet) {
|
|
122
|
-
var ex = sol.
|
|
121
|
+
var ex = sol.x1v();
|
|
123
122
|
if (ex instanceof HaltException) {
|
|
124
|
-
$this.
|
|
123
|
+
$this.d3x('# goodbye.');
|
|
125
124
|
throw new ProgramResult(ex.exitStatus);
|
|
126
125
|
} else {
|
|
127
|
-
$this.
|
|
126
|
+
$this.d3x(format(sol, Companion_instance.withOperators(operatorSet)));
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
function printEndOfSolutions($this) {
|
|
@@ -133,14 +132,13 @@
|
|
|
133
132
|
var longQuery = new StringBuilder(query);
|
|
134
133
|
var lastRead = query;
|
|
135
134
|
$l$loop: while (true) {
|
|
136
|
-
var tmp$ret$0;
|
|
137
135
|
// Inline function 'kotlin.text.trim' call
|
|
138
|
-
var
|
|
139
|
-
tmp$ret$0 = toString(trim(isCharSequence(
|
|
136
|
+
var this_0 = lastRead;
|
|
137
|
+
var tmp$ret$0 = toString(trim(isCharSequence(this_0) ? this_0 : THROW_CCE()));
|
|
140
138
|
if (!!endsWith(tmp$ret$0, _Char___init__impl__6a9atx(46))) {
|
|
141
139
|
break $l$loop;
|
|
142
140
|
}
|
|
143
|
-
var tmp0_elvis_lhs = $this.
|
|
141
|
+
var tmp0_elvis_lhs = $this.h3x('>', VOID, VOID, VOID, VOID, ' ');
|
|
144
142
|
var tmp;
|
|
145
143
|
if (tmp0_elvis_lhs == null) {
|
|
146
144
|
throw NullInputException_init_$Create$('The standard input has been closed unexpectedly');
|
|
@@ -148,12 +146,12 @@
|
|
|
148
146
|
tmp = tmp0_elvis_lhs;
|
|
149
147
|
}
|
|
150
148
|
lastRead = tmp;
|
|
151
|
-
longQuery.
|
|
149
|
+
longQuery.v5(lastRead);
|
|
152
150
|
}
|
|
153
151
|
return longQuery.toString();
|
|
154
152
|
}
|
|
155
153
|
function printNoSolution($this, sol, operatorSet) {
|
|
156
|
-
$this.
|
|
154
|
+
$this.d3x(format(sol, Companion_instance.withOperators(operatorSet)));
|
|
157
155
|
}
|
|
158
156
|
function AbstractTuPrologCommand(help, epilog, name, invokeWithoutSubcommand, printHelpOnEmptyArgs, helpTags, autoCompleteEnvvar, allowMultipleSubcommands, treatUnknownOptionsAsArgs, hidden) {
|
|
159
157
|
help = help === VOID ? '' : help;
|
|
@@ -168,48 +166,38 @@
|
|
|
168
166
|
hidden = hidden === VOID ? false : hidden;
|
|
169
167
|
CliktCommand.call(this, help, epilog, name, invokeWithoutSubcommand, printHelpOnEmptyArgs, helpTags, autoCompleteEnvvar, allowMultipleSubcommands, treatUnknownOptionsAsArgs, hidden);
|
|
170
168
|
}
|
|
171
|
-
protoOf(AbstractTuPrologCommand).
|
|
169
|
+
protoOf(AbstractTuPrologCommand).g49 = function (e) {
|
|
172
170
|
var tmp0_safe_receiver = e.message;
|
|
173
171
|
var tmp;
|
|
174
172
|
if (tmp0_safe_receiver == null) {
|
|
175
173
|
tmp = null;
|
|
176
174
|
} else {
|
|
177
|
-
var tmp$ret$4;
|
|
178
175
|
// Inline function 'kotlin.text.replaceFirstChar' call
|
|
179
176
|
var tmp_0;
|
|
180
|
-
var tmp$ret$0;
|
|
181
177
|
// Inline function 'kotlin.text.isNotEmpty' call
|
|
182
|
-
|
|
183
|
-
if (tmp$ret$0) {
|
|
184
|
-
var tmp$ret$1;
|
|
178
|
+
if (charSequenceLength(tmp0_safe_receiver) > 0) {
|
|
185
179
|
// Inline function 'it.unibo.tuprolog.ui.repl.AbstractTuPrologCommand.printParseException.<anonymous>' call
|
|
186
|
-
var
|
|
187
|
-
tmp$ret$1 = isLowerCase(
|
|
180
|
+
var it = charSequenceGet(tmp0_safe_receiver, 0);
|
|
181
|
+
var tmp$ret$1 = isLowerCase(it) ? titlecase(it) : toString_0(it);
|
|
188
182
|
var tmp_1 = toString(tmp$ret$1);
|
|
189
|
-
var tmp$ret$3;
|
|
190
183
|
// Inline function 'kotlin.text.substring' call
|
|
191
|
-
var tmp$ret$2;
|
|
192
184
|
// Inline function 'kotlin.js.asDynamic' call
|
|
193
|
-
|
|
194
|
-
tmp$ret$3 = tmp$ret$2.substring(1);
|
|
195
|
-
tmp_0 = tmp_1 + tmp$ret$3;
|
|
185
|
+
tmp_0 = tmp_1 + tmp0_safe_receiver.substring(1);
|
|
196
186
|
} else {
|
|
197
187
|
tmp_0 = tmp0_safe_receiver;
|
|
198
188
|
}
|
|
199
|
-
tmp
|
|
200
|
-
tmp = tmp$ret$4;
|
|
189
|
+
tmp = tmp_0;
|
|
201
190
|
}
|
|
202
|
-
this.
|
|
191
|
+
this.d3x('# ' + tmp, VOID, true);
|
|
203
192
|
};
|
|
204
|
-
protoOf(AbstractTuPrologCommand).
|
|
205
|
-
var query = this.
|
|
193
|
+
protoOf(AbstractTuPrologCommand).h49 = function () {
|
|
194
|
+
var query = this.h3x('?-', VOID, VOID, VOID, VOID, ' ');
|
|
206
195
|
var tmp;
|
|
207
196
|
if (query == null) {
|
|
208
197
|
throw NullInputException_init_$Create$('The standard input has been close unexpectedly');
|
|
209
198
|
} else {
|
|
210
|
-
var tmp$ret$0;
|
|
211
199
|
// Inline function 'kotlin.text.trim' call
|
|
212
|
-
tmp$ret$0 = toString(trim(
|
|
200
|
+
var tmp$ret$0 = toString(trim(isCharSequence(query) ? query : THROW_CCE()));
|
|
213
201
|
if (endsWith(tmp$ret$0, _Char___init__impl__6a9atx(46))) {
|
|
214
202
|
tmp = query;
|
|
215
203
|
} else {
|
|
@@ -218,19 +206,17 @@
|
|
|
218
206
|
}
|
|
219
207
|
return tmp;
|
|
220
208
|
};
|
|
221
|
-
protoOf(AbstractTuPrologCommand).
|
|
209
|
+
protoOf(AbstractTuPrologCommand).i49 = function (solutions, operatorSet) {
|
|
222
210
|
var first = true;
|
|
223
|
-
$l$loop: while (solutions.
|
|
211
|
+
$l$loop: while (solutions.s()) {
|
|
224
212
|
if (!first) {
|
|
225
|
-
var tmp0_safe_receiver = defaultCliktConsole().
|
|
213
|
+
var tmp0_safe_receiver = defaultCliktConsole().w44('', false);
|
|
226
214
|
var tmp;
|
|
227
215
|
if (tmp0_safe_receiver == null) {
|
|
228
216
|
tmp = null;
|
|
229
217
|
} else {
|
|
230
|
-
var tmp$ret$0;
|
|
231
218
|
// Inline function 'kotlin.text.trim' call
|
|
232
|
-
tmp
|
|
233
|
-
tmp = tmp$ret$0;
|
|
219
|
+
tmp = toString(trim(isCharSequence(tmp0_safe_receiver) ? tmp0_safe_receiver : THROW_CCE()));
|
|
234
220
|
}
|
|
235
221
|
var cmd = tmp;
|
|
236
222
|
if (!(cmd === ';'))
|
|
@@ -238,16 +224,15 @@
|
|
|
238
224
|
} else {
|
|
239
225
|
first = false;
|
|
240
226
|
}
|
|
241
|
-
printSolution(this, solutions.
|
|
227
|
+
printSolution(this, solutions.u(), operatorSet);
|
|
242
228
|
}
|
|
243
229
|
printEndOfSolutions(this);
|
|
244
230
|
};
|
|
245
|
-
protoOf(AbstractTuPrologCommand).
|
|
231
|
+
protoOf(AbstractTuPrologCommand).j49 = function (solutions, maxSolutions, operatorSet) {
|
|
246
232
|
var i = 0;
|
|
247
|
-
while (i < maxSolutions ? solutions.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
printSolution(this, solutions.n(), operatorSet);
|
|
233
|
+
while (i < maxSolutions ? solutions.s() : false) {
|
|
234
|
+
i = i + 1 | 0;
|
|
235
|
+
printSolution(this, solutions.u(), operatorSet);
|
|
251
236
|
}
|
|
252
237
|
printEndOfSolutions(this);
|
|
253
238
|
};
|
|
@@ -269,70 +254,67 @@
|
|
|
269
254
|
captureStack(this, NullInputException);
|
|
270
255
|
}
|
|
271
256
|
function Companion() {
|
|
272
|
-
|
|
273
|
-
this.h48_1 = 1000;
|
|
257
|
+
this.k49_1 = 1000;
|
|
274
258
|
}
|
|
275
|
-
var
|
|
276
|
-
function
|
|
277
|
-
|
|
278
|
-
new Companion();
|
|
279
|
-
return Companion_instance;
|
|
259
|
+
var Companion_instance_4;
|
|
260
|
+
function Companion_getInstance_1() {
|
|
261
|
+
return Companion_instance_4;
|
|
280
262
|
}
|
|
281
263
|
function _get_files__hkfg7a($this) {
|
|
282
|
-
return $this.
|
|
264
|
+
return $this.d4a_1.f45($this, files$factory_0());
|
|
283
265
|
}
|
|
284
266
|
function _get_timeout__tg4wg($this) {
|
|
285
|
-
return $this.
|
|
267
|
+
return $this.e4a_1.f45($this, timeout$factory_0());
|
|
286
268
|
}
|
|
287
269
|
function _get_oop__e6e8e9($this) {
|
|
288
|
-
return $this.
|
|
270
|
+
return $this.f4a_1.f45($this, oop$factory_0());
|
|
289
271
|
}
|
|
290
272
|
function loadTheory($this) {
|
|
291
|
-
var theory =
|
|
292
|
-
var tmp0_iterator = _get_files__hkfg7a($this).
|
|
293
|
-
while (tmp0_iterator.
|
|
294
|
-
var file = tmp0_iterator.
|
|
273
|
+
var theory = Companion_instance_0.emptyWithDefaultUnificator();
|
|
274
|
+
var tmp0_iterator = _get_files__hkfg7a($this).r();
|
|
275
|
+
while (tmp0_iterator.s()) {
|
|
276
|
+
var file = tmp0_iterator.u();
|
|
295
277
|
if (isReadableFile(file)) {
|
|
296
278
|
try {
|
|
297
279
|
var t = loadTheoryFromFile(file);
|
|
298
|
-
$this.
|
|
280
|
+
$this.d3x('# Successfully loaded ' + t.l().toString() + ' clauses from ' + file);
|
|
299
281
|
theory = theory.plusTheory(t);
|
|
300
282
|
} catch ($p) {
|
|
301
283
|
if ($p instanceof ParseException) {
|
|
302
284
|
var e = $p;
|
|
303
|
-
$this.
|
|
285
|
+
$this.d3x(trimMargin('\n |# Error while parsing theory file: ' + file + '\n |# Message: ' + e.message + '\n |# Line : ' + e.line + '\n |# Column : ' + e.column + '\n |# Clause : ' + e.clauseIndex + '\n '), VOID, true);
|
|
304
286
|
} else {
|
|
305
287
|
throw $p;
|
|
306
288
|
}
|
|
307
289
|
}
|
|
308
290
|
}
|
|
309
291
|
}
|
|
310
|
-
$this.
|
|
292
|
+
$this.d3x('');
|
|
311
293
|
return theory;
|
|
312
294
|
}
|
|
313
295
|
function readEvalPrintLoop($this, solver) {
|
|
314
296
|
try {
|
|
315
|
-
var query = $this.
|
|
297
|
+
var query = $this.h49();
|
|
316
298
|
while (!(query == null)) {
|
|
317
299
|
try {
|
|
318
|
-
var goal = parseStructWithOperators(
|
|
319
|
-
var solutions = solver.solveWithTimeout(goal, $this.
|
|
320
|
-
$this.
|
|
300
|
+
var goal = parseStructWithOperators(Companion_getInstance(), query, solver.d1v());
|
|
301
|
+
var solutions = solver.solveWithTimeout(goal, $this.g4a()).r();
|
|
302
|
+
$this.i49(solutions, solver.d1v());
|
|
321
303
|
} catch ($p) {
|
|
322
304
|
if ($p instanceof ParseException) {
|
|
323
305
|
var e = $p;
|
|
324
|
-
$this.
|
|
306
|
+
$this.g49(e);
|
|
325
307
|
} else {
|
|
326
308
|
throw $p;
|
|
327
309
|
}
|
|
328
310
|
}
|
|
329
|
-
$this.
|
|
330
|
-
query = $this.
|
|
311
|
+
$this.d3x('');
|
|
312
|
+
query = $this.h49();
|
|
331
313
|
}
|
|
332
314
|
} catch ($p) {
|
|
333
315
|
if ($p instanceof NullInputException) {
|
|
334
316
|
var _ = $p;
|
|
335
|
-
$this.
|
|
317
|
+
$this.d3x('\n# goodbye.');
|
|
336
318
|
throw new ProgramResult(0);
|
|
337
319
|
} else {
|
|
338
320
|
throw $p;
|
|
@@ -346,76 +328,63 @@
|
|
|
346
328
|
}
|
|
347
329
|
function TuPrologCmd$getSolver$lambda(this$0) {
|
|
348
330
|
return function (w) {
|
|
349
|
-
this$0.
|
|
331
|
+
this$0.d3x('# ' + w.message, VOID, true);
|
|
350
332
|
var sep = '\n at ';
|
|
351
|
-
var formatter =
|
|
352
|
-
var tmp = w.
|
|
333
|
+
var formatter = Companion_instance_1.prettyExpressionsPrettyVariables(w.uc().d1v());
|
|
334
|
+
var tmp = w.r1u();
|
|
353
335
|
var stacktrace = joinToString(tmp, sep, VOID, VOID, VOID, VOID, TuPrologCmd$getSolver$lambda$lambda(formatter));
|
|
354
|
-
this$0.
|
|
355
|
-
return
|
|
336
|
+
this$0.d3x('# at ' + stacktrace, VOID, true);
|
|
337
|
+
return Unit_instance;
|
|
356
338
|
};
|
|
357
339
|
}
|
|
358
340
|
function TuPrologCmd$getSolver$lambda_0($this$flag) {
|
|
359
|
-
return $this$flag.
|
|
341
|
+
return $this$flag.z28_1;
|
|
360
342
|
}
|
|
361
343
|
function TuPrologCmd(additionalLibraries) {
|
|
362
|
-
Companion_getInstance_6();
|
|
363
344
|
AbstractTuPrologCommand.call(this, 'Start a Prolog Read-Eval-Print loop', VOID, 'java -jar 2p-repl.jar', true, VOID, VOID, VOID, true);
|
|
364
|
-
this.
|
|
365
|
-
this.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
protoOf(TuPrologCmd).z3w = function () {
|
|
374
|
-
var solve = this.e49();
|
|
375
|
-
var subcommand = this.y29().u3u_1;
|
|
345
|
+
this.c4a_1 = additionalLibraries;
|
|
346
|
+
this.d4a_1 = multiple(option(this, ['-T', '--theory'], 'Path of theory file to be loaded')).o46(this, files$factory());
|
|
347
|
+
this.e4a_1 = default_0(int(option(this, ['-t', '--timeout'], 'Maximum amount of time for computing a solution (default: 1000 ms)')), 1000).o46(this, timeout$factory());
|
|
348
|
+
this.f4a_1 = flag(option(this, ['--oop'], 'Loads the OOP library'), [], false).o46(this, oop$factory());
|
|
349
|
+
}
|
|
350
|
+
protoOf(TuPrologCmd).c3y = function () {
|
|
351
|
+
var solve = this.h4a();
|
|
352
|
+
var subcommand = this.a2b().x3v_1;
|
|
376
353
|
if (subcommand == null) {
|
|
377
354
|
readEvalPrintLoop(this, solve);
|
|
378
355
|
}
|
|
379
356
|
};
|
|
380
|
-
protoOf(TuPrologCmd).
|
|
357
|
+
protoOf(TuPrologCmd).g4a = function () {
|
|
381
358
|
return toLong(_get_timeout__tg4wg(this));
|
|
382
359
|
};
|
|
383
|
-
protoOf(TuPrologCmd).
|
|
360
|
+
protoOf(TuPrologCmd).h4a = function () {
|
|
384
361
|
Info_getInstance();
|
|
385
|
-
this.
|
|
362
|
+
this.d3x('# 2P-Kt version ' + '0.32.1');
|
|
386
363
|
var theory = loadTheory(this);
|
|
387
|
-
var tmp =
|
|
364
|
+
var tmp = Companion_instance_2;
|
|
388
365
|
var outputChannel = tmp.of(TuPrologCmd$getSolver$lambda(this));
|
|
389
366
|
var tmp_0;
|
|
390
367
|
if (_get_oop__e6e8e9(this)) {
|
|
391
|
-
tmp_0 =
|
|
368
|
+
tmp_0 = Companion_instance_3.of(arrayConcat([[IOLib_getInstance(), OOPLib_getInstance()], this.c4a_1]));
|
|
392
369
|
} else {
|
|
393
|
-
tmp_0 =
|
|
370
|
+
tmp_0 = Companion_instance_3.of(arrayConcat([[IOLib_getInstance()], this.c4a_1]));
|
|
394
371
|
}
|
|
395
372
|
var libraries = tmp_0;
|
|
396
|
-
var tmp$ret$2;
|
|
397
373
|
// Inline function 'kotlin.also' call
|
|
398
|
-
var tmp_1 =
|
|
374
|
+
var tmp_1 = Companion_getInstance_0().m1x().newBuilder().setRuntime(libraries).setStaticKb(theory);
|
|
399
375
|
var tmp_2 = TrackVariables_getInstance();
|
|
400
|
-
var
|
|
376
|
+
var this_0 = tmp_1.setNotableFlagByValue(tmp_2, TuPrologCmd$getSolver$lambda_0).setWarnings(outputChannel).build();
|
|
401
377
|
// Inline function 'kotlin.contracts.contract' call
|
|
402
378
|
// Inline function 'it.unibo.tuprolog.ui.repl.TuPrologCmd.getSolver.<anonymous>' call
|
|
403
|
-
var tmp$ret$0;
|
|
404
379
|
// Inline function 'kotlin.collections.iterator' call
|
|
405
|
-
var tmp0_iterator =
|
|
406
|
-
|
|
407
|
-
var tmp0_iterator_0 = tmp$ret$0;
|
|
408
|
-
while (tmp0_iterator_0.m()) {
|
|
409
|
-
var tmp1_loop_parameter = tmp0_iterator_0.n();
|
|
410
|
-
var tmp$ret$1;
|
|
380
|
+
var tmp0_iterator = this_0.u1u().p2().r();
|
|
381
|
+
while (tmp0_iterator.s()) {
|
|
411
382
|
// Inline function 'kotlin.collections.component2' call
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this.a3w('# Successfully loaded library `' + library.q2c() + '`');
|
|
383
|
+
var library = tmp0_iterator.u().r2();
|
|
384
|
+
this.d3x('# Successfully loaded library `' + library.s2d() + '`');
|
|
415
385
|
}
|
|
416
|
-
this.
|
|
417
|
-
|
|
418
|
-
return tmp$ret$2;
|
|
386
|
+
this.d3x('');
|
|
387
|
+
return this_0;
|
|
419
388
|
};
|
|
420
389
|
function files$factory() {
|
|
421
390
|
return getPropertyCallableRef('files', 1, KProperty1, function (receiver) {
|
|
@@ -448,50 +417,49 @@
|
|
|
448
417
|
}, null);
|
|
449
418
|
}
|
|
450
419
|
function _get_query__c6g9vb($this) {
|
|
451
|
-
return $this.
|
|
420
|
+
return $this.z4a_1.f45($this, query$factory_0());
|
|
452
421
|
}
|
|
453
422
|
function _get_maxSolutions__ysux2t($this) {
|
|
454
|
-
return $this.
|
|
423
|
+
return $this.a4b_1.f45($this, maxSolutions$factory_0());
|
|
455
424
|
}
|
|
456
425
|
function _get_parentCommand__z09ff4($this) {
|
|
457
|
-
var tmp0_safe_receiver = $this.
|
|
458
|
-
var tmp = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.
|
|
426
|
+
var tmp0_safe_receiver = $this.a2b().h3v_1;
|
|
427
|
+
var tmp = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.i3v_1;
|
|
459
428
|
return tmp instanceof TuPrologCmd ? tmp : THROW_CCE();
|
|
460
429
|
}
|
|
461
430
|
function evalAndPrint($this, solver) {
|
|
462
|
-
var tmp$ret$0;
|
|
463
431
|
// Inline function 'kotlin.text.isNotEmpty' call
|
|
464
|
-
var
|
|
465
|
-
|
|
466
|
-
if (tmp$ret$0) {
|
|
432
|
+
var this_0 = _get_query__c6g9vb($this);
|
|
433
|
+
if (charSequenceLength(this_0) > 0) {
|
|
467
434
|
try {
|
|
468
|
-
var duration = _get_parentCommand__z09ff4($this).
|
|
469
|
-
var solutions = solver.solveWithTimeout(parseStruct(
|
|
435
|
+
var duration = _get_parentCommand__z09ff4($this).g4a();
|
|
436
|
+
var solutions = solver.solveWithTimeout(parseStruct(Companion_getInstance(), _get_query__c6g9vb($this)), duration).r();
|
|
470
437
|
if (_get_maxSolutions__ysux2t($this) === 0) {
|
|
471
|
-
$this.
|
|
438
|
+
$this.i49(solutions, solver.d1v());
|
|
472
439
|
} else {
|
|
473
|
-
$this.
|
|
440
|
+
$this.j49(solutions, _get_maxSolutions__ysux2t($this), solver.d1v());
|
|
474
441
|
}
|
|
475
442
|
} catch ($p) {
|
|
476
443
|
if ($p instanceof ParseException) {
|
|
477
444
|
var e = $p;
|
|
478
|
-
$this.
|
|
445
|
+
$this.g49(e);
|
|
479
446
|
} else {
|
|
480
447
|
throw $p;
|
|
481
448
|
}
|
|
482
449
|
}
|
|
483
450
|
} else {
|
|
484
451
|
// Inline function 'kotlin.TODO' call
|
|
485
|
-
|
|
452
|
+
var reason = 'throw adequate exception';
|
|
453
|
+
throw new NotImplementedError('An operation is not implemented: ' + reason);
|
|
486
454
|
}
|
|
487
455
|
}
|
|
488
456
|
function TuPrologSolveQuery() {
|
|
489
457
|
AbstractTuPrologCommand.call(this, 'Compute a particular query and then terminate', VOID, 'solve');
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
458
|
+
this.z4a_1 = argument(this).g45(this, query$factory());
|
|
459
|
+
this.a4b_1 = default_0(int(option(this, ['-n', '--numberOfSolutions'], 'Number of solution to calculate')), 0).o46(this, maxSolutions$factory());
|
|
492
460
|
}
|
|
493
|
-
protoOf(TuPrologSolveQuery).
|
|
494
|
-
var solver = _get_parentCommand__z09ff4(this).
|
|
461
|
+
protoOf(TuPrologSolveQuery).c3y = function () {
|
|
462
|
+
var solver = _get_parentCommand__z09ff4(this).h4a();
|
|
495
463
|
evalAndPrint(this, solver);
|
|
496
464
|
};
|
|
497
465
|
function query$factory() {
|
|
@@ -516,15 +484,20 @@
|
|
|
516
484
|
}
|
|
517
485
|
function isReadableFile(path) {
|
|
518
486
|
// Inline function 'kotlin.TODO' call
|
|
519
|
-
|
|
487
|
+
var reason = 'Not yet implemented';
|
|
488
|
+
throw new NotImplementedError('An operation is not implemented: ' + reason);
|
|
520
489
|
}
|
|
521
490
|
function loadTheoryFromFile(path) {
|
|
522
491
|
// Inline function 'kotlin.TODO' call
|
|
523
|
-
|
|
492
|
+
var reason = 'Not yet implemented';
|
|
493
|
+
throw new NotImplementedError('An operation is not implemented: ' + reason);
|
|
524
494
|
}
|
|
525
495
|
function main(args) {
|
|
526
|
-
subcommands(new TuPrologCmd([]), [new TuPrologSolveQuery()]).
|
|
496
|
+
subcommands(new TuPrologCmd([]), [new TuPrologSolveQuery()]).b3y(args);
|
|
527
497
|
}
|
|
498
|
+
//region block: init
|
|
499
|
+
Companion_instance_4 = new Companion();
|
|
500
|
+
//endregion
|
|
528
501
|
//region block: exports
|
|
529
502
|
_.$_$ = _.$_$ || {};
|
|
530
503
|
_.$_$.a = main;
|