@tuprolog/2p-full 1.0.3 → 1.1.0
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 +204 -201
- package/2p-bdd.js.map +1 -1
- package/2p-core.js +3668 -4128
- package/2p-core.js.map +1 -1
- package/2p-datalog.js +3 -3
- package/2p-datalog.js.map +1 -1
- package/2p-dsl-core.js +3 -3
- package/2p-dsl-core.js.map +1 -1
- package/2p-dsl-solve.js +3 -3
- package/2p-dsl-solve.js.map +1 -1
- package/2p-dsl-theory.js +3 -3
- package/2p-dsl-theory.js.map +1 -1
- package/2p-dsl-unify.js +3 -3
- package/2p-dsl-unify.js.map +1 -1
- package/2p-full.js +9 -19
- package/2p-full.js.map +1 -1
- package/2p-io-lib.js +6 -3321
- package/2p-io-lib.js.map +1 -1
- package/2p-oop-lib.js +6 -3435
- package/2p-oop-lib.js.map +1 -1
- package/2p-parser-core.js +6 -1266
- package/2p-parser-core.js.map +1 -1
- package/2p-parser-js.js +6 -30
- package/2p-parser-js.js.map +1 -1
- package/2p-parser-theory.js +6 -126
- package/2p-parser-theory.js.map +1 -1
- package/2p-repl.js +6 -499
- package/2p-repl.js.map +1 -1
- package/2p-serialize-core.js +3 -3
- package/2p-serialize-core.js.map +1 -1
- package/2p-serialize-theory.js +3 -3
- package/2p-serialize-theory.js.map +1 -1
- package/2p-solve-classic.js +1216 -1203
- package/2p-solve-classic.js.map +1 -1
- package/2p-solve-concurrent.js +3 -3
- package/2p-solve-concurrent.js.map +1 -1
- package/2p-solve-plp.js +8 -8
- package/2p-solve-plp.js.map +1 -1
- package/2p-solve-problog.js +2095 -2140
- package/2p-solve-problog.js.map +1 -1
- package/2p-solve-streams.js +1244 -1333
- package/2p-solve-streams.js.map +1 -1
- package/2p-solve.js +5185 -6393
- package/2p-solve.js.map +1 -1
- package/2p-test-dsl.js +3 -3
- package/2p-test-dsl.js.map +1 -1
- package/2p-theory.js +2091 -1992
- package/2p-theory.js.map +1 -1
- package/2p-unify.js +315 -300
- package/2p-unify.js.map +1 -1
- package/2p-utils.js +625 -635
- package/2p-utils.js.map +1 -1
- package/clikt-clikt-mordant.js +15 -0
- package/clikt-clikt-mordant.js.map +1 -0
- package/clikt-clikt.js +15 -0
- package/clikt-clikt.js.map +1 -0
- package/colormath-root-colormath.js +15 -0
- package/colormath-root-colormath.js.map +1 -0
- package/kotlin-kotlin-stdlib.js +6829 -8585
- package/kotlin-kotlin-stdlib.js.map +1 -1
- package/kotlin-kotlin-test.js +15 -0
- package/kotlin-kotlin-test.js.map +1 -0
- package/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.js +3 -3
- package/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.js.map +1 -1
- package/kotlinx-atomicfu.js +15 -0
- package/kotlinx-atomicfu.js.map +1 -0
- package/kotlinx-coroutines-core.js +15 -0
- package/kotlinx-coroutines-core.js.map +1 -0
- package/kt-math.js +3143 -3508
- package/kt-math.js.map +1 -1
- package/mordant-mordant-omnibus.js +15 -0
- package/mordant-mordant-omnibus.js.map +1 -0
- package/mordant-mordant.js +19 -0
- package/mordant-mordant.js.map +1 -0
- package/package.json +2 -3
- package/88b0986a7186d029-atomicfu-js-ir.js +0 -15
- package/88b0986a7186d029-atomicfu-js-ir.js.map +0 -1
- package/clikt-clikt-js-ir.js +0 -6006
- package/clikt-clikt-js-ir.js.map +0 -1
- package/kotlin-kotlin-test-kotlin-test-js-ir.js +0 -15
- package/kotlin-kotlin-test-kotlin-test-js-ir.js.map +0 -1
- package/kotlin-kotlinx-atomicfu-runtime-js-ir.js +0 -15
- package/kotlin-kotlinx-atomicfu-runtime-js-ir.js.map +0 -1
- package/kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js +0 -15
- package/kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js.map +0 -1
package/2p-parser-core.js
CHANGED
|
@@ -1,1273 +1,13 @@
|
|
|
1
|
-
(function (
|
|
1
|
+
(function (factory) {
|
|
2
2
|
if (typeof define === 'function' && define.amd)
|
|
3
|
-
define(['exports'
|
|
3
|
+
define(['exports'], factory);
|
|
4
4
|
else if (typeof exports === 'object')
|
|
5
|
-
factory(module.exports
|
|
6
|
-
else
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
if (typeof antlr4 === 'undefined') {
|
|
11
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency 'antlr4' was not found. Please, check whether 'antlr4' is loaded prior to '2p-parser-core'.");
|
|
12
|
-
}
|
|
13
|
-
if (typeof this['antlr4/src/antlr4/error'] === 'undefined') {
|
|
14
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency 'antlr4/src/antlr4/error' was not found. Please, check whether 'antlr4/src/antlr4/error' is loaded prior to '2p-parser-core'.");
|
|
15
|
-
}
|
|
16
|
-
if (typeof this['antlr4/src/antlr4/atn'] === 'undefined') {
|
|
17
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency 'antlr4/src/antlr4/atn' was not found. Please, check whether 'antlr4/src/antlr4/atn' is loaded prior to '2p-parser-core'.");
|
|
18
|
-
}
|
|
19
|
-
if (typeof this['kotlin-kotlin-stdlib'] === 'undefined') {
|
|
20
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to '2p-parser-core'.");
|
|
21
|
-
}
|
|
22
|
-
if (typeof this['2p-core'] === 'undefined') {
|
|
23
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency '2p-core' was not found. Please, check whether '2p-core' is loaded prior to '2p-parser-core'.");
|
|
24
|
-
}
|
|
25
|
-
if (typeof this['2p-parser-js'] === 'undefined') {
|
|
26
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency '2p-parser-js' was not found. Please, check whether '2p-parser-js' is loaded prior to '2p-parser-core'.");
|
|
27
|
-
}
|
|
28
|
-
if (typeof this['kt-math'] === 'undefined') {
|
|
29
|
-
throw new Error("Error loading module '2p-parser-core'. Its dependency 'kt-math' was not found. Please, check whether 'kt-math' is loaded prior to '2p-parser-core'.");
|
|
30
|
-
}
|
|
31
|
-
root['2p-parser-core'] = factory(typeof this['2p-parser-core'] === 'undefined' ? {} : this['2p-parser-core'], this['@tuprolog/parser-utils'], antlr4, this['antlr4/src/antlr4/error'], this['antlr4/src/antlr4/atn'], this['kotlin-kotlin-stdlib'], this['2p-core'], this['2p-parser-js'], this['kt-math']);
|
|
32
|
-
}
|
|
33
|
-
}(this, function (_, $module$_tuprolog_parser_utils_xy31vy, $module$antlr4, $module$antlr4_src_antlr4_error_s9pni7, $module$antlr4_src_antlr4_atn_66gh9q, kotlin_kotlin, kotlin_it_unibo_tuprolog_core, kotlin_it_unibo_tuprolog_parser_js, kotlin_io_github_gciatto_kt_math) {
|
|
5
|
+
factory(module.exports);
|
|
6
|
+
else
|
|
7
|
+
globalThis['2p-parser-core'] = factory(typeof globalThis['2p-parser-core'] === 'undefined' ? {} : globalThis['2p-parser-core']);
|
|
8
|
+
}(function (_) {
|
|
34
9
|
'use strict';
|
|
35
|
-
//region block: imports
|
|
36
|
-
var PrologParserListener = $module$_tuprolog_parser_utils_xy31vy.PrologParserListener;
|
|
37
|
-
var Associativity = $module$_tuprolog_parser_utils_xy31vy.Associativity;
|
|
38
|
-
var Token = $module$antlr4.Token;
|
|
39
|
-
var RecognitionException = $module$antlr4_src_antlr4_error_s9pni7.RecognitionException;
|
|
40
|
-
var PredictionMode = $module$antlr4_src_antlr4_atn_66gh9q.PredictionMode;
|
|
41
|
-
var PrologParser = $module$_tuprolog_parser_utils_xy31vy.PrologParser;
|
|
42
|
-
var InputStream = $module$antlr4.InputStream;
|
|
43
|
-
var PrologLexer = $module$_tuprolog_parser_utils_xy31vy.PrologLexer;
|
|
44
|
-
var CommonTokenStream = $module$antlr4.CommonTokenStream;
|
|
45
|
-
var BailErrorStrategy = $module$antlr4_src_antlr4_error_s9pni7.BailErrorStrategy;
|
|
46
|
-
var PrologParserVisitor = $module$_tuprolog_parser_utils_xy31vy.PrologParserVisitor;
|
|
47
|
-
var VOID = kotlin_kotlin.$_$.d;
|
|
48
|
-
var captureStack = kotlin_kotlin.$_$.q5;
|
|
49
|
-
var protoOf = kotlin_kotlin.$_$.u6;
|
|
50
|
-
var classMeta = kotlin_kotlin.$_$.v5;
|
|
51
|
-
var setMetadataFor = kotlin_kotlin.$_$.v6;
|
|
52
|
-
var TuPrologException = kotlin_it_unibo_tuprolog_core.$_$.l1;
|
|
53
|
-
var TuPrologException_init_$Init$ = kotlin_it_unibo_tuprolog_core.$_$.m;
|
|
54
|
-
var ensureNotNull = kotlin_kotlin.$_$.yb;
|
|
55
|
-
var replace = kotlin_kotlin.$_$.ha;
|
|
56
|
-
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.k1;
|
|
57
|
-
var Char = kotlin_kotlin.$_$.hb;
|
|
58
|
-
var toString = kotlin_kotlin.$_$.o1;
|
|
59
|
-
var Struct = kotlin_it_unibo_tuprolog_core.$_$.z1;
|
|
60
|
-
var isInterface = kotlin_kotlin.$_$.j6;
|
|
61
|
-
var Numeric = kotlin_it_unibo_tuprolog_core.$_$.w1;
|
|
62
|
-
var Atom = kotlin_it_unibo_tuprolog_core.$_$.o1;
|
|
63
|
-
var Companion_getInstance = kotlin_it_unibo_tuprolog_core.$_$.q;
|
|
64
|
-
var Companion_instance = kotlin_it_unibo_tuprolog_core.$_$.c1;
|
|
65
|
-
var OperatorSet_init_$Create$ = kotlin_it_unibo_tuprolog_core.$_$.n;
|
|
66
|
-
var objectMeta = kotlin_kotlin.$_$.t6;
|
|
67
|
-
var getKClass = kotlin_kotlin.$_$.c;
|
|
68
|
-
var Constant = kotlin_it_unibo_tuprolog_core.$_$.q1;
|
|
69
|
-
var Var = kotlin_it_unibo_tuprolog_core.$_$.b3;
|
|
70
|
-
var Integer = kotlin_it_unibo_tuprolog_core.$_$.u1;
|
|
71
|
-
var Real = kotlin_it_unibo_tuprolog_core.$_$.x1;
|
|
72
|
-
var Clause = kotlin_it_unibo_tuprolog_core.$_$.p1;
|
|
73
|
-
var Rule = kotlin_it_unibo_tuprolog_core.$_$.y1;
|
|
74
|
-
var Fact = kotlin_it_unibo_tuprolog_core.$_$.s1;
|
|
75
|
-
var Directive = kotlin_it_unibo_tuprolog_core.$_$.r1;
|
|
76
|
-
var interfaceMeta = kotlin_kotlin.$_$.f6;
|
|
77
|
-
var Companion_instance_0 = kotlin_it_unibo_tuprolog_core.$_$.v;
|
|
78
|
-
var Unit_instance = kotlin_kotlin.$_$.y1;
|
|
79
|
-
var THROW_CCE = kotlin_kotlin.$_$.vb;
|
|
80
|
-
var contains = kotlin_kotlin.$_$.s2;
|
|
81
|
-
var Companion_getInstance_0 = kotlin_it_unibo_tuprolog_core.$_$.r;
|
|
82
|
-
var map = kotlin_kotlin.$_$.q8;
|
|
83
|
-
var Operator = kotlin_it_unibo_tuprolog_core.$_$.n1;
|
|
84
|
-
var List = kotlin_it_unibo_tuprolog_core.$_$.v1;
|
|
85
|
-
var toString_0 = kotlin_kotlin.$_$.z6;
|
|
86
|
-
var coerceAtLeast = kotlin_kotlin.$_$.k7;
|
|
87
|
-
var isRecognitionException = kotlin_it_unibo_tuprolog_parser_js.$_$.b;
|
|
88
|
-
var isParseCancellationException = kotlin_it_unibo_tuprolog_parser_js.$_$.a;
|
|
89
|
-
var generateSequence = kotlin_kotlin.$_$.j8;
|
|
90
|
-
var takeWhile = kotlin_kotlin.$_$.z8;
|
|
91
|
-
var to = kotlin_kotlin.$_$.hc;
|
|
92
|
-
var Companion_getInstance_1 = kotlin_io_github_gciatto_kt_math.$_$.e;
|
|
93
|
-
var charSequenceGet = kotlin_kotlin.$_$.t5;
|
|
94
|
-
var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.n1;
|
|
95
|
-
var contains_0 = kotlin_kotlin.$_$.m9;
|
|
96
|
-
var plus = kotlin_kotlin.$_$.cc;
|
|
97
|
-
var ArrayList_init_$Create$ = kotlin_kotlin.$_$.f;
|
|
98
|
-
var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.y;
|
|
99
|
-
var listOf = kotlin_kotlin.$_$.r3;
|
|
100
|
-
var asList = kotlin_kotlin.$_$.j2;
|
|
101
|
-
var plus_0 = kotlin_kotlin.$_$.k4;
|
|
102
|
-
var collectionSizeOrDefault = kotlin_kotlin.$_$.q2;
|
|
103
|
-
var toList = kotlin_kotlin.$_$.x4;
|
|
104
|
-
var flatMap = kotlin_kotlin.$_$.h8;
|
|
105
|
-
var asSequence = kotlin_kotlin.$_$.n2;
|
|
106
|
-
var toList_0 = kotlin_kotlin.$_$.d9;
|
|
107
|
-
var sequenceOf = kotlin_kotlin.$_$.w8;
|
|
108
|
-
var asSequence_0 = kotlin_kotlin.$_$.o2;
|
|
109
|
-
var plus_1 = kotlin_kotlin.$_$.u8;
|
|
110
|
-
var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.v;
|
|
111
|
-
var Term = kotlin_it_unibo_tuprolog_core.$_$.y2;
|
|
112
|
-
var Companion_getInstance_2 = kotlin_it_unibo_tuprolog_core.$_$.x;
|
|
113
|
-
var Companion_getInstance_3 = kotlin_it_unibo_tuprolog_core.$_$.a1;
|
|
114
|
-
var NumberFormatException = kotlin_kotlin.$_$.sb;
|
|
115
|
-
//endregion
|
|
116
10
|
//region block: pre-declaration
|
|
117
|
-
setMetadataFor(ParseException, 'ParseException', classMeta, TuPrologException);
|
|
118
|
-
setMetadataFor(InvalidTermTypeException, 'InvalidTermTypeException', classMeta, ParseException);
|
|
119
|
-
setMetadataFor(Companion, 'Companion', objectMeta);
|
|
120
|
-
function parseTerm(input) {
|
|
121
|
-
return this.parseTermWithOperators(input, this.r3i());
|
|
122
|
-
}
|
|
123
|
-
function parseStructWithOperators(input, operators) {
|
|
124
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
125
|
-
// Inline function 'kotlin.let' call
|
|
126
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
127
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
128
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
129
|
-
var tmp0_elvis_lhs = isInterface(it, Struct) ? it : null;
|
|
130
|
-
var tmp;
|
|
131
|
-
if (tmp0_elvis_lhs == null) {
|
|
132
|
-
throw new InvalidTermTypeException(input, it, getKClass(Struct));
|
|
133
|
-
} else {
|
|
134
|
-
tmp = tmp0_elvis_lhs;
|
|
135
|
-
}
|
|
136
|
-
return tmp;
|
|
137
|
-
}
|
|
138
|
-
function parseStruct(input) {
|
|
139
|
-
return this.parseStructWithOperators(input, this.r3i());
|
|
140
|
-
}
|
|
141
|
-
function parseConstantWithOperators(input, operators) {
|
|
142
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
143
|
-
// Inline function 'kotlin.let' call
|
|
144
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
145
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
146
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
147
|
-
var tmp0_elvis_lhs = isInterface(it, Constant) ? it : null;
|
|
148
|
-
var tmp;
|
|
149
|
-
if (tmp0_elvis_lhs == null) {
|
|
150
|
-
throw new InvalidTermTypeException(input, it, getKClass(Constant));
|
|
151
|
-
} else {
|
|
152
|
-
tmp = tmp0_elvis_lhs;
|
|
153
|
-
}
|
|
154
|
-
return tmp;
|
|
155
|
-
}
|
|
156
|
-
function parseConstant(input) {
|
|
157
|
-
return this.parseConstantWithOperators(input, this.r3i());
|
|
158
|
-
}
|
|
159
|
-
function parseVarWithOperators(input, operators) {
|
|
160
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
161
|
-
// Inline function 'kotlin.let' call
|
|
162
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
163
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
164
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
165
|
-
var tmp0_elvis_lhs = isInterface(it, Var) ? it : null;
|
|
166
|
-
var tmp;
|
|
167
|
-
if (tmp0_elvis_lhs == null) {
|
|
168
|
-
throw new InvalidTermTypeException(input, it, getKClass(Var));
|
|
169
|
-
} else {
|
|
170
|
-
tmp = tmp0_elvis_lhs;
|
|
171
|
-
}
|
|
172
|
-
return tmp;
|
|
173
|
-
}
|
|
174
|
-
function parseVar(input) {
|
|
175
|
-
return this.parseVarWithOperators(input, this.r3i());
|
|
176
|
-
}
|
|
177
|
-
function parseAtomWithOperators(input, operators) {
|
|
178
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
179
|
-
// Inline function 'kotlin.let' call
|
|
180
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
181
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
182
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
183
|
-
var tmp0_elvis_lhs = isInterface(it, Atom) ? it : null;
|
|
184
|
-
var tmp;
|
|
185
|
-
if (tmp0_elvis_lhs == null) {
|
|
186
|
-
throw new InvalidTermTypeException(input, it, getKClass(Atom));
|
|
187
|
-
} else {
|
|
188
|
-
tmp = tmp0_elvis_lhs;
|
|
189
|
-
}
|
|
190
|
-
return tmp;
|
|
191
|
-
}
|
|
192
|
-
function parseAtom(input) {
|
|
193
|
-
return this.parseAtomWithOperators(input, this.r3i());
|
|
194
|
-
}
|
|
195
|
-
function parseNumericWithOperators(input, operators) {
|
|
196
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
197
|
-
// Inline function 'kotlin.let' call
|
|
198
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
199
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
200
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
201
|
-
var tmp0_elvis_lhs = isInterface(it, Numeric) ? it : null;
|
|
202
|
-
var tmp;
|
|
203
|
-
if (tmp0_elvis_lhs == null) {
|
|
204
|
-
throw new InvalidTermTypeException(input, it, getKClass(Numeric));
|
|
205
|
-
} else {
|
|
206
|
-
tmp = tmp0_elvis_lhs;
|
|
207
|
-
}
|
|
208
|
-
return tmp;
|
|
209
|
-
}
|
|
210
|
-
function parseNumeric(input) {
|
|
211
|
-
return this.parseNumericWithOperators(input, this.r3i());
|
|
212
|
-
}
|
|
213
|
-
function parseIntegerWithOperators(input, operators) {
|
|
214
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
215
|
-
// Inline function 'kotlin.let' call
|
|
216
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
217
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
218
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
219
|
-
var tmp0_elvis_lhs = isInterface(it, Integer) ? it : null;
|
|
220
|
-
var tmp;
|
|
221
|
-
if (tmp0_elvis_lhs == null) {
|
|
222
|
-
throw new InvalidTermTypeException(input, it, getKClass(Integer));
|
|
223
|
-
} else {
|
|
224
|
-
tmp = tmp0_elvis_lhs;
|
|
225
|
-
}
|
|
226
|
-
return tmp;
|
|
227
|
-
}
|
|
228
|
-
function parseInteger(input) {
|
|
229
|
-
return this.parseIntegerWithOperators(input, this.r3i());
|
|
230
|
-
}
|
|
231
|
-
function parseRealWithOperators(input, operators) {
|
|
232
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
233
|
-
// Inline function 'kotlin.let' call
|
|
234
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
235
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
236
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
237
|
-
var tmp0_elvis_lhs = isInterface(it, Real) ? it : null;
|
|
238
|
-
var tmp;
|
|
239
|
-
if (tmp0_elvis_lhs == null) {
|
|
240
|
-
throw new InvalidTermTypeException(input, it, getKClass(Real));
|
|
241
|
-
} else {
|
|
242
|
-
tmp = tmp0_elvis_lhs;
|
|
243
|
-
}
|
|
244
|
-
return tmp;
|
|
245
|
-
}
|
|
246
|
-
function parseReal(input) {
|
|
247
|
-
return this.parseRealWithOperators(input, this.r3i());
|
|
248
|
-
}
|
|
249
|
-
function parseClauseWithOperators(input, operators) {
|
|
250
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
251
|
-
// Inline function 'kotlin.let' call
|
|
252
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
253
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
254
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
255
|
-
var tmp0_elvis_lhs = isInterface(it, Clause) ? it : null;
|
|
256
|
-
var tmp;
|
|
257
|
-
if (tmp0_elvis_lhs == null) {
|
|
258
|
-
throw new InvalidTermTypeException(input, it, getKClass(Clause));
|
|
259
|
-
} else {
|
|
260
|
-
tmp = tmp0_elvis_lhs;
|
|
261
|
-
}
|
|
262
|
-
return tmp;
|
|
263
|
-
}
|
|
264
|
-
function parseClause(input) {
|
|
265
|
-
return this.parseClauseWithOperators(input, this.r3i());
|
|
266
|
-
}
|
|
267
|
-
function parseRuleWithOperators(input, operators) {
|
|
268
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
269
|
-
// Inline function 'kotlin.let' call
|
|
270
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
271
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
272
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
273
|
-
var tmp0_elvis_lhs = isInterface(it, Rule) ? it : null;
|
|
274
|
-
var tmp;
|
|
275
|
-
if (tmp0_elvis_lhs == null) {
|
|
276
|
-
throw new InvalidTermTypeException(input, it, getKClass(Rule));
|
|
277
|
-
} else {
|
|
278
|
-
tmp = tmp0_elvis_lhs;
|
|
279
|
-
}
|
|
280
|
-
return tmp;
|
|
281
|
-
}
|
|
282
|
-
function parseRule(input) {
|
|
283
|
-
return this.parseRuleWithOperators(input, this.r3i());
|
|
284
|
-
}
|
|
285
|
-
function parseFactWithOperators(input, operators) {
|
|
286
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
287
|
-
// Inline function 'kotlin.let' call
|
|
288
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
289
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
290
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
291
|
-
var tmp0_elvis_lhs = isInterface(it, Fact) ? it : null;
|
|
292
|
-
var tmp;
|
|
293
|
-
if (tmp0_elvis_lhs == null) {
|
|
294
|
-
throw new InvalidTermTypeException(input, it, getKClass(Fact));
|
|
295
|
-
} else {
|
|
296
|
-
tmp = tmp0_elvis_lhs;
|
|
297
|
-
}
|
|
298
|
-
return tmp;
|
|
299
|
-
}
|
|
300
|
-
function parseFact(input) {
|
|
301
|
-
return this.parseFactWithOperators(input, this.r3i());
|
|
302
|
-
}
|
|
303
|
-
function parseDirectiveWithOperators(input, operators) {
|
|
304
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
|
|
305
|
-
// Inline function 'kotlin.let' call
|
|
306
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
307
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs.<anonymous>' call
|
|
308
|
-
var it = this.parseTermWithOperators(input, operators);
|
|
309
|
-
var tmp0_elvis_lhs = isInterface(it, Directive) ? it : null;
|
|
310
|
-
var tmp;
|
|
311
|
-
if (tmp0_elvis_lhs == null) {
|
|
312
|
-
throw new InvalidTermTypeException(input, it, getKClass(Directive));
|
|
313
|
-
} else {
|
|
314
|
-
tmp = tmp0_elvis_lhs;
|
|
315
|
-
}
|
|
316
|
-
return tmp;
|
|
317
|
-
}
|
|
318
|
-
function parseDirective(input) {
|
|
319
|
-
return this.parseDirectiveWithOperators(input, this.r3i());
|
|
320
|
-
}
|
|
321
|
-
setMetadataFor(TermParser, 'TermParser', interfaceMeta);
|
|
322
|
-
setMetadataFor(Companion_0, 'Companion', objectMeta);
|
|
323
|
-
setMetadataFor(DynamicOpListener, 'DynamicOpListener', classMeta, PrologParserListener);
|
|
324
|
-
setMetadataFor(PrologParserFactory$newErrorListener$1, VOID, classMeta);
|
|
325
|
-
setMetadataFor(PrologParserFactory, 'PrologParserFactory', objectMeta);
|
|
326
|
-
setMetadataFor(PrologVisitor, 'PrologVisitor', classMeta, PrologParserVisitor, VOID, PrologVisitor);
|
|
327
|
-
setMetadataFor(TermParserImpl, 'TermParserImpl', classMeta, VOID, [TermParser]);
|
|
328
|
-
//endregion
|
|
329
|
-
function InvalidTermTypeException(input, term, type, offendingSymbol, line, column, message, throwable) {
|
|
330
|
-
var tmp;
|
|
331
|
-
if (offendingSymbol === VOID) {
|
|
332
|
-
var tmp0_elvis_lhs = (!(input == null) ? typeof input === 'string' : false) ? input : null;
|
|
333
|
-
tmp = tmp0_elvis_lhs == null ? term.toString() : tmp0_elvis_lhs;
|
|
334
|
-
} else {
|
|
335
|
-
tmp = offendingSymbol;
|
|
336
|
-
}
|
|
337
|
-
offendingSymbol = tmp;
|
|
338
|
-
line = line === VOID ? 1 : line;
|
|
339
|
-
column = column === VOID ? 1 : column;
|
|
340
|
-
message = message === VOID ? 'Expected ' + type.s6() + ', got: ' + offendingSymbol : message;
|
|
341
|
-
throwable = throwable === VOID ? null : throwable;
|
|
342
|
-
ParseException.call(this, input, offendingSymbol, line, column, message, throwable);
|
|
343
|
-
captureStack(this, InvalidTermTypeException);
|
|
344
|
-
this.a3i_1 = term;
|
|
345
|
-
this.b3i_1 = type;
|
|
346
|
-
}
|
|
347
|
-
function ParseException(input, offendingSymbol, line, column, message, throwable) {
|
|
348
|
-
TuPrologException_init_$Init$(message, throwable, this);
|
|
349
|
-
captureStack(this, ParseException);
|
|
350
|
-
this.input = input;
|
|
351
|
-
this.offendingSymbol = offendingSymbol;
|
|
352
|
-
this.line = line;
|
|
353
|
-
this.column = column;
|
|
354
|
-
this.clauseIndex = -1;
|
|
355
|
-
}
|
|
356
|
-
protoOf(ParseException).c3i = function (_set____db54di) {
|
|
357
|
-
this.input = _set____db54di;
|
|
358
|
-
};
|
|
359
|
-
protoOf(ParseException).d3i = function () {
|
|
360
|
-
return this.input;
|
|
361
|
-
};
|
|
362
|
-
protoOf(ParseException).e3i = function (_set____db54di) {
|
|
363
|
-
this.offendingSymbol = _set____db54di;
|
|
364
|
-
};
|
|
365
|
-
protoOf(ParseException).f3i = function () {
|
|
366
|
-
return this.offendingSymbol;
|
|
367
|
-
};
|
|
368
|
-
protoOf(ParseException).g3i = function (_set____db54di) {
|
|
369
|
-
this.line = _set____db54di;
|
|
370
|
-
};
|
|
371
|
-
protoOf(ParseException).h3i = function () {
|
|
372
|
-
return this.line;
|
|
373
|
-
};
|
|
374
|
-
protoOf(ParseException).i3i = function (_set____db54di) {
|
|
375
|
-
this.column = _set____db54di;
|
|
376
|
-
};
|
|
377
|
-
protoOf(ParseException).j3i = function () {
|
|
378
|
-
return this.column;
|
|
379
|
-
};
|
|
380
|
-
protoOf(ParseException).k3i = function (_set____db54di) {
|
|
381
|
-
this.clauseIndex = _set____db54di;
|
|
382
|
-
};
|
|
383
|
-
protoOf(ParseException).l3i = function () {
|
|
384
|
-
return this.clauseIndex;
|
|
385
|
-
};
|
|
386
|
-
protoOf(ParseException).toString = function () {
|
|
387
|
-
return "ParseException{message='" + replace(ensureNotNull(this.message), '\\n', '\\\\n') + new Char(_Char___init__impl__6a9atx(39)) + ', line=' + this.line + ', column=' + this.column + ", offendingSymbol='" + this.offendingSymbol + new Char(_Char___init__impl__6a9atx(39)) + toString(_Char___init__impl__6a9atx(125));
|
|
388
|
-
};
|
|
389
|
-
function get_isOpDirective(_this__u8e3s4) {
|
|
390
|
-
var tmp;
|
|
391
|
-
var tmp_0;
|
|
392
|
-
var tmp_1;
|
|
393
|
-
var tmp_2;
|
|
394
|
-
var tmp_3;
|
|
395
|
-
if (isInterface(_this__u8e3s4, Struct)) {
|
|
396
|
-
tmp_3 = _this__u8e3s4.kw() === 3;
|
|
397
|
-
} else {
|
|
398
|
-
tmp_3 = false;
|
|
399
|
-
}
|
|
400
|
-
if (tmp_3) {
|
|
401
|
-
tmp_2 = _this__u8e3s4.qw() === 'op';
|
|
402
|
-
} else {
|
|
403
|
-
tmp_2 = false;
|
|
404
|
-
}
|
|
405
|
-
if (tmp_2) {
|
|
406
|
-
tmp_1 = _this__u8e3s4.ux();
|
|
407
|
-
} else {
|
|
408
|
-
tmp_1 = false;
|
|
409
|
-
}
|
|
410
|
-
if (tmp_1) {
|
|
411
|
-
var tmp_4 = _this__u8e3s4.get(0);
|
|
412
|
-
tmp_0 = isInterface(tmp_4, Numeric);
|
|
413
|
-
} else {
|
|
414
|
-
tmp_0 = false;
|
|
415
|
-
}
|
|
416
|
-
if (tmp_0) {
|
|
417
|
-
var tmp_5 = _this__u8e3s4.get(1);
|
|
418
|
-
tmp = isInterface(tmp_5, Atom);
|
|
419
|
-
} else {
|
|
420
|
-
tmp = false;
|
|
421
|
-
}
|
|
422
|
-
return tmp;
|
|
423
|
-
}
|
|
424
|
-
function Companion() {
|
|
425
|
-
}
|
|
426
|
-
protoOf(Companion).m3i = function (scope) {
|
|
427
|
-
return this.n3i(Companion_getInstance().EMPTY, scope);
|
|
428
|
-
};
|
|
429
|
-
protoOf(Companion).withNoOperator = function (scope, $super) {
|
|
430
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
431
|
-
return $super === VOID ? this.m3i(scope) : $super.m3i.call(this, scope);
|
|
432
|
-
};
|
|
433
|
-
protoOf(Companion).o3i = function (scope) {
|
|
434
|
-
return this.n3i(Companion_getInstance().STANDARD, scope);
|
|
435
|
-
};
|
|
436
|
-
protoOf(Companion).withStandardOperators = function (scope, $super) {
|
|
437
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
438
|
-
return $super === VOID ? this.o3i(scope) : $super.o3i.call(this, scope);
|
|
439
|
-
};
|
|
440
|
-
protoOf(Companion).p3i = function (scope) {
|
|
441
|
-
return this.n3i(Companion_getInstance().DEFAULT, scope);
|
|
442
|
-
};
|
|
443
|
-
protoOf(Companion).withDefaultOperators = function (scope, $super) {
|
|
444
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
445
|
-
return $super === VOID ? this.p3i(scope) : $super.p3i.call(this, scope);
|
|
446
|
-
};
|
|
447
|
-
protoOf(Companion).n3i = function (operators, scope) {
|
|
448
|
-
return termParserWithOperators(operators, scope);
|
|
449
|
-
};
|
|
450
|
-
protoOf(Companion).withOperatorSet = function (operators, scope, $super) {
|
|
451
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
452
|
-
return $super === VOID ? this.n3i(operators, scope) : $super.n3i.call(this, operators, scope);
|
|
453
|
-
};
|
|
454
|
-
protoOf(Companion).q3i = function (operators, scope) {
|
|
455
|
-
return this.n3i(OperatorSet_init_$Create$(operators.slice()), scope);
|
|
456
|
-
};
|
|
457
|
-
protoOf(Companion).withOperators = function (operators, scope, $super) {
|
|
458
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
459
|
-
return $super === VOID ? this.q3i(operators, scope) : $super.q3i.call(this, operators, scope);
|
|
460
|
-
};
|
|
461
|
-
var Companion_instance_1;
|
|
462
|
-
function Companion_getInstance_4() {
|
|
463
|
-
return Companion_instance_1;
|
|
464
|
-
}
|
|
465
|
-
function TermParser() {
|
|
466
|
-
}
|
|
467
|
-
function termToClause(_this__u8e3s4, source, line, column) {
|
|
468
|
-
source = source === VOID ? null : source;
|
|
469
|
-
line = line === VOID ? 0 : line;
|
|
470
|
-
column = column === VOID ? 0 : column;
|
|
471
|
-
var tmp;
|
|
472
|
-
if (isInterface(_this__u8e3s4, Clause)) {
|
|
473
|
-
tmp = _this__u8e3s4;
|
|
474
|
-
} else {
|
|
475
|
-
if (isInterface(_this__u8e3s4, Struct)) {
|
|
476
|
-
tmp = Companion_instance_0.of(_this__u8e3s4);
|
|
477
|
-
} else {
|
|
478
|
-
throw new InvalidTermTypeException(source, _this__u8e3s4, getKClass(Clause), VOID, line, column);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return tmp;
|
|
482
|
-
}
|
|
483
|
-
function parseStructWithOperators_0(_this__u8e3s4, input, operators) {
|
|
484
|
-
return get_defaultParser().parseStructWithOperators(input, operators);
|
|
485
|
-
}
|
|
486
|
-
function parseStruct_0(_this__u8e3s4, input) {
|
|
487
|
-
return get_defaultParser().parseStruct(input);
|
|
488
|
-
}
|
|
489
|
-
function get_defaultParser() {
|
|
490
|
-
return Companion_instance_1.withDefaultOperators();
|
|
491
|
-
}
|
|
492
|
-
function toAssociativity(_this__u8e3s4) {
|
|
493
|
-
return _this__u8e3s4.toString();
|
|
494
|
-
}
|
|
495
|
-
function DynamicOpListener$Companion$of$lambda($this$$receiver, it) {
|
|
496
|
-
return Unit_instance;
|
|
497
|
-
}
|
|
498
|
-
function onOperatorDefined($this, operator) {
|
|
499
|
-
$this.s3i_1.addOperator(operator.l1i_1, toAssociativity(operator.m1i_1), operator.n1i_1);
|
|
500
|
-
$this.t3i_1($this.s3i_1, operator);
|
|
501
|
-
}
|
|
502
|
-
function Companion_0() {
|
|
503
|
-
}
|
|
504
|
-
protoOf(Companion_0).u3i = function (parser) {
|
|
505
|
-
return new DynamicOpListener(parser, DynamicOpListener$Companion$of$lambda);
|
|
506
|
-
};
|
|
507
|
-
var Companion_instance_2;
|
|
508
|
-
function Companion_getInstance_5() {
|
|
509
|
-
return Companion_instance_2;
|
|
510
|
-
}
|
|
511
|
-
function DynamicOpListener$exitClause$lambda(it) {
|
|
512
|
-
return isInterface(it, Atom) ? it : THROW_CCE();
|
|
513
|
-
}
|
|
514
|
-
function DynamicOpListener(parser, operatorDefinedCallback) {
|
|
515
|
-
PrologParserListener.call(this);
|
|
516
|
-
this.s3i_1 = parser;
|
|
517
|
-
this.t3i_1 = operatorDefinedCallback;
|
|
518
|
-
}
|
|
519
|
-
protoOf(DynamicOpListener).v3i = function (ctx) {
|
|
520
|
-
var expr = ctx.expression();
|
|
521
|
-
if (ctx.exception != null) {
|
|
522
|
-
return Unit_instance;
|
|
523
|
-
}
|
|
524
|
-
var tmp;
|
|
525
|
-
var tmp_0;
|
|
526
|
-
if (!(expr._op == null)) {
|
|
527
|
-
var tmp0_safe_receiver = expr._op;
|
|
528
|
-
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.symbol;
|
|
529
|
-
tmp_0 = ':-' === (tmp1_safe_receiver == null ? null : tmp1_safe_receiver.text);
|
|
530
|
-
} else {
|
|
531
|
-
tmp_0 = false;
|
|
532
|
-
}
|
|
533
|
-
if (tmp_0) {
|
|
534
|
-
tmp = contains(Associativity.PREFIX, expr.associativity);
|
|
535
|
-
} else {
|
|
536
|
-
tmp = false;
|
|
537
|
-
}
|
|
538
|
-
if (tmp) {
|
|
539
|
-
var tmp_1 = ctx.accept(new PrologVisitor());
|
|
540
|
-
var directive = isInterface(tmp_1, Directive) ? tmp_1 : THROW_CCE();
|
|
541
|
-
var op = directive.xy();
|
|
542
|
-
if (get_isOpDirective(op)) {
|
|
543
|
-
// Inline function 'kotlin.math.min' call
|
|
544
|
-
// Inline function 'kotlin.math.max' call
|
|
545
|
-
var tmp_2 = (isInterface(op, Struct) ? op : THROW_CCE()).get(0);
|
|
546
|
-
var b = (isInterface(tmp_2, Numeric) ? tmp_2 : THROW_CCE()).y10().toInt();
|
|
547
|
-
var b_0 = Math.max(0, b);
|
|
548
|
-
var priority = Math.min(1200, b_0);
|
|
549
|
-
var specifier = Companion_getInstance_0().fromTerm(op.get(1));
|
|
550
|
-
var operator = op.get(2);
|
|
551
|
-
if (isInterface(operator, Atom)) {
|
|
552
|
-
onOperatorDefined(this, new Operator(operator.r2(), specifier, priority));
|
|
553
|
-
} else {
|
|
554
|
-
if (isInterface(operator, List)) {
|
|
555
|
-
var tmp$ret$3;
|
|
556
|
-
$l$block: {
|
|
557
|
-
// Inline function 'kotlin.sequences.all' call
|
|
558
|
-
var tmp0_iterator = operator.uu().r();
|
|
559
|
-
while (tmp0_iterator.s()) {
|
|
560
|
-
var element = tmp0_iterator.u();
|
|
561
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.DynamicOpListener.exitClause.<anonymous>' call
|
|
562
|
-
if (!isInterface(element, Atom)) {
|
|
563
|
-
tmp$ret$3 = false;
|
|
564
|
-
break $l$block;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
tmp$ret$3 = true;
|
|
568
|
-
}
|
|
569
|
-
if (tmp$ret$3) {
|
|
570
|
-
var tmp_3 = operator.uu();
|
|
571
|
-
var tmp2_iterator = map(tmp_3, DynamicOpListener$exitClause$lambda).r();
|
|
572
|
-
while (tmp2_iterator.s()) {
|
|
573
|
-
var it = tmp2_iterator.u();
|
|
574
|
-
onOperatorDefined(this, new Operator(it.r2(), specifier, priority));
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
protoOf(DynamicOpListener).exitClause = function (ctx) {
|
|
583
|
-
return this.v3i(ctx);
|
|
584
|
-
};
|
|
585
|
-
function parseException(token, message) {
|
|
586
|
-
return new ParseException(null, token.text, token.line, token.column, message, null);
|
|
587
|
-
}
|
|
588
|
-
function symbolToString($this, obj) {
|
|
589
|
-
var tmp;
|
|
590
|
-
if (obj instanceof Token) {
|
|
591
|
-
tmp = obj.text;
|
|
592
|
-
} else {
|
|
593
|
-
tmp = toString_0(obj);
|
|
594
|
-
}
|
|
595
|
-
return tmp;
|
|
596
|
-
}
|
|
597
|
-
function newErrorListener($this, whileParsing) {
|
|
598
|
-
return new PrologParserFactory$newErrorListener$1(whileParsing);
|
|
599
|
-
}
|
|
600
|
-
function parseExpression($this, parserAndErrorStrategy, source) {
|
|
601
|
-
var mark = -1;
|
|
602
|
-
var index = -1;
|
|
603
|
-
var parser = parserAndErrorStrategy.ye_1;
|
|
604
|
-
var tmp;
|
|
605
|
-
try {
|
|
606
|
-
mark = parser.getTokenStream().mark();
|
|
607
|
-
index = coerceAtLeast(parser.getTokenStream().index, 0);
|
|
608
|
-
tmp = parser.singletonExpression();
|
|
609
|
-
} catch ($p) {
|
|
610
|
-
var tmp_0;
|
|
611
|
-
var e = $p;
|
|
612
|
-
var tmp_1;
|
|
613
|
-
if (isParseCancellationException(e) ? parser._interp.predictionMode === PredictionMode.SLL : false) {
|
|
614
|
-
parser.getTokenStream().seek(index);
|
|
615
|
-
parser._interp.predictionMode = PredictionMode.LL;
|
|
616
|
-
parser._errHandler = parserAndErrorStrategy.ze_1;
|
|
617
|
-
parser.addErrorListener(newErrorListener($this, source));
|
|
618
|
-
tmp_1 = parseExpression($this, parserAndErrorStrategy, source);
|
|
619
|
-
} else if (e.clause !== null ? isRecognitionException(e.cause) : false) {
|
|
620
|
-
var tmp_2 = e.cause;
|
|
621
|
-
throw tmp_2 instanceof RecognitionException ? tmp_2 : THROW_CCE();
|
|
622
|
-
} else {
|
|
623
|
-
throw e instanceof Error ? e : THROW_CCE();
|
|
624
|
-
}
|
|
625
|
-
tmp_0 = tmp_1;
|
|
626
|
-
tmp = tmp_0;
|
|
627
|
-
}
|
|
628
|
-
finally {
|
|
629
|
-
parser.getTokenStream().release(mark);
|
|
630
|
-
}
|
|
631
|
-
return tmp;
|
|
632
|
-
}
|
|
633
|
-
function parseClause_0($this, parserAndErrorStrategy, source) {
|
|
634
|
-
var mark = -1;
|
|
635
|
-
var index = -1;
|
|
636
|
-
var parser = parserAndErrorStrategy.ye_1;
|
|
637
|
-
var tmp;
|
|
638
|
-
try {
|
|
639
|
-
mark = parser.getTokenStream().mark();
|
|
640
|
-
index = coerceAtLeast(parser.getTokenStream().index, 0);
|
|
641
|
-
tmp = parser.optClause();
|
|
642
|
-
} catch ($p) {
|
|
643
|
-
var tmp_0;
|
|
644
|
-
var e = $p;
|
|
645
|
-
var tmp_1;
|
|
646
|
-
if (isParseCancellationException(e) ? parser._interp.predictionMode === PredictionMode.SLL : false) {
|
|
647
|
-
parser.getTokenStream().seek(index);
|
|
648
|
-
parser._interp.predictionMode = PredictionMode.LL;
|
|
649
|
-
parser._errHandler = parserAndErrorStrategy.ze_1;
|
|
650
|
-
parser.addErrorListener(newErrorListener($this, source));
|
|
651
|
-
tmp_1 = parseClause_0($this, parserAndErrorStrategy, source);
|
|
652
|
-
} else if (e.clause !== null ? isRecognitionException(e.cause) : false) {
|
|
653
|
-
var tmp_2 = e.cause;
|
|
654
|
-
throw tmp_2 instanceof RecognitionException ? tmp_2 : THROW_CCE();
|
|
655
|
-
} else {
|
|
656
|
-
throw e instanceof Error ? e : THROW_CCE();
|
|
657
|
-
}
|
|
658
|
-
tmp_0 = tmp_1;
|
|
659
|
-
tmp = tmp_0;
|
|
660
|
-
}
|
|
661
|
-
finally {
|
|
662
|
-
parser.getTokenStream().release(mark);
|
|
663
|
-
}
|
|
664
|
-
return tmp;
|
|
665
|
-
}
|
|
666
|
-
function parseClauses($this, parser, source) {
|
|
667
|
-
var tmp = generateSequence(0, PrologParserFactory$parseClauses$lambda);
|
|
668
|
-
var tmp_0 = map(tmp, PrologParserFactory$parseClauses$lambda_0(parser, source));
|
|
669
|
-
var tmp_1 = takeWhile(tmp_0, PrologParserFactory$parseClauses$lambda_1);
|
|
670
|
-
return map(tmp_1, PrologParserFactory$parseClauses$lambda_2);
|
|
671
|
-
}
|
|
672
|
-
function PrologParserFactory$newErrorListener$1($whileParsing) {
|
|
673
|
-
this.w3i_1 = $whileParsing;
|
|
674
|
-
}
|
|
675
|
-
protoOf(PrologParserFactory$newErrorListener$1).syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
|
|
676
|
-
if (recognizer instanceof PrologParser) {
|
|
677
|
-
recognizer.removeParseListeners();
|
|
678
|
-
}
|
|
679
|
-
throw new ParseException(this.w3i_1, symbolToString(this, offendingSymbol), line, column + 1 | 0, msg, e);
|
|
680
|
-
};
|
|
681
|
-
function PrologParserFactory$parseClauses$lambda(it) {
|
|
682
|
-
return it + 1 | 0;
|
|
683
|
-
}
|
|
684
|
-
function PrologParserFactory$parseClauses$lambda_0($parser, $source) {
|
|
685
|
-
return function (it) {
|
|
686
|
-
var tmp;
|
|
687
|
-
try {
|
|
688
|
-
tmp = parseClause_0(PrologParserFactory_instance, $parser, $source);
|
|
689
|
-
} catch ($p) {
|
|
690
|
-
var tmp_0;
|
|
691
|
-
if ($p instanceof ParseException) {
|
|
692
|
-
var e = $p;
|
|
693
|
-
e.clauseIndex = it;
|
|
694
|
-
throw e;
|
|
695
|
-
} else {
|
|
696
|
-
throw $p;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return tmp;
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
function PrologParserFactory$parseClauses$lambda_1(it) {
|
|
703
|
-
return !it.isOver;
|
|
704
|
-
}
|
|
705
|
-
function PrologParserFactory$parseClauses$lambda_2(it) {
|
|
706
|
-
return it.clause();
|
|
707
|
-
}
|
|
708
|
-
function PrologParserFactory() {
|
|
709
|
-
}
|
|
710
|
-
protoOf(PrologParserFactory).x3i = function (string, withOperators) {
|
|
711
|
-
var parser = this.y3i(string, withOperators);
|
|
712
|
-
return parseExpression(this, parser, string);
|
|
713
|
-
};
|
|
714
|
-
protoOf(PrologParserFactory).z3i = function (source, withOperators) {
|
|
715
|
-
var parser = this.y3i(source, withOperators);
|
|
716
|
-
return parseClauses(this, parser, source);
|
|
717
|
-
};
|
|
718
|
-
protoOf(PrologParserFactory).y3i = function (source, operators) {
|
|
719
|
-
var stream = new InputStream(source);
|
|
720
|
-
var lexer = new PrologLexer(stream);
|
|
721
|
-
lexer.removeErrorListeners();
|
|
722
|
-
var tokenStream = new CommonTokenStream(lexer);
|
|
723
|
-
var parser = new PrologParser(tokenStream);
|
|
724
|
-
parser.removeErrorListeners();
|
|
725
|
-
var originalErrorStrategy = parser._errHandler;
|
|
726
|
-
parser._errHandler = new BailErrorStrategy();
|
|
727
|
-
parser._interp.predictionMode = PredictionMode.SLL;
|
|
728
|
-
return to(this.a3j(parser, operators), originalErrorStrategy);
|
|
729
|
-
};
|
|
730
|
-
protoOf(PrologParserFactory).a3j = function (prologParser, operators) {
|
|
731
|
-
// Inline function 'kotlin.collections.forEach' call
|
|
732
|
-
var tmp0_iterator = operators.r();
|
|
733
|
-
while (tmp0_iterator.s()) {
|
|
734
|
-
var element = tmp0_iterator.u();
|
|
735
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologParserFactory.addOperators.<anonymous>' call
|
|
736
|
-
prologParser.addOperator(element.l1i_1, toAssociativity(element.m1i_1), element.n1i_1);
|
|
737
|
-
}
|
|
738
|
-
prologParser.addParseListener(Companion_instance_2.u3i(prologParser));
|
|
739
|
-
return prologParser;
|
|
740
|
-
};
|
|
741
|
-
var PrologParserFactory_instance;
|
|
742
|
-
function PrologParserFactory_getInstance() {
|
|
743
|
-
return PrologParserFactory_instance;
|
|
744
|
-
}
|
|
745
|
-
function parseInteger_0($this, ctx) {
|
|
746
|
-
var str = ctx.value.text;
|
|
747
|
-
var base;
|
|
748
|
-
var clean;
|
|
749
|
-
if (ctx.isBin) {
|
|
750
|
-
base = 2;
|
|
751
|
-
// Inline function 'kotlin.text.substring' call
|
|
752
|
-
// Inline function 'kotlin.js.asDynamic' call
|
|
753
|
-
clean = str.substring(2);
|
|
754
|
-
} else if (ctx.isOct) {
|
|
755
|
-
base = 8;
|
|
756
|
-
// Inline function 'kotlin.text.substring' call
|
|
757
|
-
// Inline function 'kotlin.js.asDynamic' call
|
|
758
|
-
clean = str.substring(2);
|
|
759
|
-
} else if (ctx.isHex) {
|
|
760
|
-
base = 16;
|
|
761
|
-
// Inline function 'kotlin.text.substring' call
|
|
762
|
-
// Inline function 'kotlin.js.asDynamic' call
|
|
763
|
-
clean = str.substring(2);
|
|
764
|
-
} else if (ctx.isChar) {
|
|
765
|
-
// Inline function 'kotlin.text.substring' call
|
|
766
|
-
// Inline function 'kotlin.js.asDynamic' call
|
|
767
|
-
clean = str.substring(2);
|
|
768
|
-
if (!(clean.length === 1)) {
|
|
769
|
-
throw parseException(ctx.value, 'Invalid character literal: ' + ctx.value.text);
|
|
770
|
-
}
|
|
771
|
-
// Inline function 'kotlin.with' call
|
|
772
|
-
var tmp = Companion_getInstance_1();
|
|
773
|
-
// Inline function 'kotlin.code' call
|
|
774
|
-
var this_0 = charSequenceGet(clean, 0);
|
|
775
|
-
var tmp$ret$8 = Char__toInt_impl_vasixd(this_0);
|
|
776
|
-
// Inline function 'kotlin.contracts.contract' call
|
|
777
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.parseInteger.<anonymous>' call
|
|
778
|
-
var $this$with = tmp.of(tmp$ret$8);
|
|
779
|
-
var tmp_0;
|
|
780
|
-
var tmp0_safe_receiver = ctx.sign;
|
|
781
|
-
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text;
|
|
782
|
-
var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : contains_0(tmp1_safe_receiver, '-');
|
|
783
|
-
if (tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs) {
|
|
784
|
-
tmp_0 = $this$with.unaryMinus();
|
|
785
|
-
} else {
|
|
786
|
-
tmp_0 = $this$with;
|
|
787
|
-
}
|
|
788
|
-
return tmp_0;
|
|
789
|
-
} else {
|
|
790
|
-
base = 10;
|
|
791
|
-
clean = str;
|
|
792
|
-
}
|
|
793
|
-
if (!(ctx.sign == null)) {
|
|
794
|
-
var tmp0_safe_receiver_0 = ctx.sign;
|
|
795
|
-
clean = plus(tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0.text, clean);
|
|
796
|
-
}
|
|
797
|
-
return Companion_getInstance_1().parseWithRadix(clean, base);
|
|
798
|
-
}
|
|
799
|
-
function visitPostfixExpression($this, ctx) {
|
|
800
|
-
var tmp0_safe_receiver = ctx.left;
|
|
801
|
-
var tmp = ensureNotNull(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept($this));
|
|
802
|
-
// Inline function 'kotlin.collections.map' call
|
|
803
|
-
var this_0 = ctx.operators;
|
|
804
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
805
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
806
|
-
var inductionVariable = 0;
|
|
807
|
-
var last = this_0.length;
|
|
808
|
-
while (inductionVariable < last) {
|
|
809
|
-
var item = this_0[inductionVariable];
|
|
810
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
811
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitPostfixExpression.<anonymous>' call
|
|
812
|
-
var tmp$ret$0 = item.symbol.text;
|
|
813
|
-
destination.o(tmp$ret$0);
|
|
814
|
-
}
|
|
815
|
-
return postfix($this, tmp, destination);
|
|
816
|
-
}
|
|
817
|
-
function postfix($this, term, ops) {
|
|
818
|
-
var operator = ops.r();
|
|
819
|
-
var result = $this.b3j_1.structOf(operator.u(), [term]);
|
|
820
|
-
while (operator.s()) {
|
|
821
|
-
result = $this.b3j_1.structOf(operator.u(), [result]);
|
|
822
|
-
}
|
|
823
|
-
return result;
|
|
824
|
-
}
|
|
825
|
-
function visitPrefixExpression($this, ctx) {
|
|
826
|
-
var tmp = ctx.right[0].accept($this);
|
|
827
|
-
// Inline function 'kotlin.collections.map' call
|
|
828
|
-
var this_0 = ctx.operators;
|
|
829
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
830
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
831
|
-
var inductionVariable = 0;
|
|
832
|
-
var last = this_0.length;
|
|
833
|
-
while (inductionVariable < last) {
|
|
834
|
-
var item = this_0[inductionVariable];
|
|
835
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
836
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitPrefixExpression.<anonymous>' call
|
|
837
|
-
var tmp$ret$0 = item.symbol.text;
|
|
838
|
-
destination.o(tmp$ret$0);
|
|
839
|
-
}
|
|
840
|
-
return prefix($this, tmp, destination);
|
|
841
|
-
}
|
|
842
|
-
function prefix($this, term, ops) {
|
|
843
|
-
var i = ops.l() - 1 | 0;
|
|
844
|
-
var tmp0 = i;
|
|
845
|
-
i = tmp0 - 1 | 0;
|
|
846
|
-
var result = $this.b3j_1.structOf(ops.c1(tmp0), [term]);
|
|
847
|
-
while (i >= 0) {
|
|
848
|
-
result = $this.b3j_1.structOf(ops.c1(i), [result]);
|
|
849
|
-
i = i - 1 | 0;
|
|
850
|
-
}
|
|
851
|
-
return result;
|
|
852
|
-
}
|
|
853
|
-
function visitInfixExpression($this, ctx) {
|
|
854
|
-
var tmp0_subject = ctx.associativity;
|
|
855
|
-
var tmp;
|
|
856
|
-
if (tmp0_subject === Associativity.XFY) {
|
|
857
|
-
tmp = visitInfixRightAssociativeExpression($this, ctx);
|
|
858
|
-
} else if (tmp0_subject === Associativity.YFX) {
|
|
859
|
-
tmp = visitInfixLeftAssociativeExpression($this, ctx);
|
|
860
|
-
} else if (tmp0_subject === Associativity.XFX) {
|
|
861
|
-
tmp = visitInfixNonAssociativeExpression($this, ctx);
|
|
862
|
-
} else {
|
|
863
|
-
var message = 'Non-infix associativity ' + ctx.associativity + ' in infix expression';
|
|
864
|
-
throw IllegalStateException_init_$Create$(toString_0(message));
|
|
865
|
-
}
|
|
866
|
-
return tmp;
|
|
867
|
-
}
|
|
868
|
-
function visitInfixNonAssociativeExpression($this, ctx) {
|
|
869
|
-
// Inline function 'kotlin.collections.map' call
|
|
870
|
-
var this_0 = plus_0(listOf(ensureNotNull(ctx.left)), asList(ctx.right));
|
|
871
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
872
|
-
var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
|
|
873
|
-
var tmp0_iterator = this_0.r();
|
|
874
|
-
while (tmp0_iterator.s()) {
|
|
875
|
-
var item = tmp0_iterator.u();
|
|
876
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitInfixNonAssociativeExpression.<anonymous>' call
|
|
877
|
-
var tmp$ret$0 = item.accept($this);
|
|
878
|
-
destination.o(tmp$ret$0);
|
|
879
|
-
}
|
|
880
|
-
var operands = destination;
|
|
881
|
-
// Inline function 'kotlin.collections.map' call
|
|
882
|
-
var this_1 = ctx.operators;
|
|
883
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
884
|
-
var destination_0 = ArrayList_init_$Create$(this_1.length);
|
|
885
|
-
var inductionVariable = 0;
|
|
886
|
-
var last = this_1.length;
|
|
887
|
-
while (inductionVariable < last) {
|
|
888
|
-
var item_0 = this_1[inductionVariable];
|
|
889
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
890
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitInfixNonAssociativeExpression.<anonymous>' call
|
|
891
|
-
var tmp$ret$3 = item_0.symbol.text;
|
|
892
|
-
destination_0.o(tmp$ret$3);
|
|
893
|
-
}
|
|
894
|
-
var operators = destination_0;
|
|
895
|
-
return infixNonAssociative($this, operands, operators);
|
|
896
|
-
}
|
|
897
|
-
function infixNonAssociative($this, terms, ops) {
|
|
898
|
-
return $this.b3j_1.structOf(ops.c1(0), [terms.c1(0), terms.c1(1)]);
|
|
899
|
-
}
|
|
900
|
-
function handleOuters($this, expression, outers) {
|
|
901
|
-
var result = expression;
|
|
902
|
-
var tmp0_iterator = outers.r();
|
|
903
|
-
while (tmp0_iterator.s()) {
|
|
904
|
-
var o = tmp0_iterator.u();
|
|
905
|
-
var tmp = listOf(result);
|
|
906
|
-
// Inline function 'kotlin.collections.map' call
|
|
907
|
-
var this_0 = o.right;
|
|
908
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
909
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
910
|
-
var inductionVariable = 0;
|
|
911
|
-
var last = this_0.length;
|
|
912
|
-
while (inductionVariable < last) {
|
|
913
|
-
var item = this_0[inductionVariable];
|
|
914
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
915
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.handleOuters.<anonymous>' call
|
|
916
|
-
var tmp$ret$0 = item.accept($this);
|
|
917
|
-
destination.o(tmp$ret$0);
|
|
918
|
-
}
|
|
919
|
-
var operands = plus_0(tmp, destination);
|
|
920
|
-
// Inline function 'kotlin.collections.map' call
|
|
921
|
-
var this_1 = o.operators;
|
|
922
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
923
|
-
var destination_0 = ArrayList_init_$Create$(this_1.length);
|
|
924
|
-
var inductionVariable_0 = 0;
|
|
925
|
-
var last_0 = this_1.length;
|
|
926
|
-
while (inductionVariable_0 < last_0) {
|
|
927
|
-
var item_0 = this_1[inductionVariable_0];
|
|
928
|
-
inductionVariable_0 = inductionVariable_0 + 1 | 0;
|
|
929
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.handleOuters.<anonymous>' call
|
|
930
|
-
var tmp$ret$3 = item_0.symbol.text;
|
|
931
|
-
destination_0.o(tmp$ret$3);
|
|
932
|
-
}
|
|
933
|
-
var operators = destination_0;
|
|
934
|
-
var associativity = o.associativity;
|
|
935
|
-
var tmp_0;
|
|
936
|
-
if (associativity === Associativity.XFY) {
|
|
937
|
-
tmp_0 = infixRight($this, operands, operators);
|
|
938
|
-
} else if (associativity === Associativity.XF ? true : associativity === Associativity.YF) {
|
|
939
|
-
tmp_0 = postfix($this, result, operators);
|
|
940
|
-
} else if (associativity === Associativity.XFX) {
|
|
941
|
-
tmp_0 = infixNonAssociative($this, operands, operators);
|
|
942
|
-
} else if (associativity === Associativity.YFX) {
|
|
943
|
-
tmp_0 = infixLeft($this, operands, operators);
|
|
944
|
-
} else if (associativity === Associativity.FX ? true : associativity === Associativity.FY) {
|
|
945
|
-
tmp_0 = prefix($this, result, operators);
|
|
946
|
-
} else {
|
|
947
|
-
var message = 'Invalid associativity: ' + associativity;
|
|
948
|
-
throw IllegalStateException_init_$Create$(toString_0(message));
|
|
949
|
-
}
|
|
950
|
-
result = tmp_0;
|
|
951
|
-
}
|
|
952
|
-
return result;
|
|
953
|
-
}
|
|
954
|
-
function infixRight($this, terms, ops) {
|
|
955
|
-
var i = terms.l() - 1 | 0;
|
|
956
|
-
var j = ops.l() - 1 | 0;
|
|
957
|
-
var tmp0 = j;
|
|
958
|
-
j = tmp0 - 1 | 0;
|
|
959
|
-
var result = $this.b3j_1.structOf(ops.c1(tmp0), [terms.c1(i - 1 | 0), terms.c1(i)]);
|
|
960
|
-
i = i - 2 | 0;
|
|
961
|
-
while (i >= 0) {
|
|
962
|
-
var tmp1 = j;
|
|
963
|
-
j = tmp1 - 1 | 0;
|
|
964
|
-
result = $this.b3j_1.structOf(ops.c1(tmp1), [terms.c1(i), result]);
|
|
965
|
-
i = i - 1 | 0;
|
|
966
|
-
}
|
|
967
|
-
return result;
|
|
968
|
-
}
|
|
969
|
-
function infixLeft($this, terms, ops) {
|
|
970
|
-
var i = 0;
|
|
971
|
-
var j = 0;
|
|
972
|
-
var tmp0 = j;
|
|
973
|
-
j = tmp0 + 1 | 0;
|
|
974
|
-
var tmp = ops.c1(tmp0);
|
|
975
|
-
var tmp1 = i;
|
|
976
|
-
i = tmp1 + 1 | 0;
|
|
977
|
-
var tmp_0 = terms.c1(tmp1);
|
|
978
|
-
var tmp2 = i;
|
|
979
|
-
i = tmp2 + 1 | 0;
|
|
980
|
-
var result = $this.b3j_1.structOf(tmp, [tmp_0, terms.c1(tmp2)]);
|
|
981
|
-
while (i < terms.l()) {
|
|
982
|
-
var tmp3 = j;
|
|
983
|
-
j = tmp3 + 1 | 0;
|
|
984
|
-
result = $this.b3j_1.structOf(ops.c1(tmp3), [result, terms.c1(i)]);
|
|
985
|
-
i = i + 1 | 0;
|
|
986
|
-
}
|
|
987
|
-
return result;
|
|
988
|
-
}
|
|
989
|
-
function listOfOperands($this, ctx) {
|
|
990
|
-
// Inline function 'kotlin.collections.map' call
|
|
991
|
-
var this_0 = plus_0(listOf(ctx.left), toList(ctx.right));
|
|
992
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
993
|
-
var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
|
|
994
|
-
var tmp0_iterator = this_0.r();
|
|
995
|
-
while (tmp0_iterator.s()) {
|
|
996
|
-
var item = tmp0_iterator.u();
|
|
997
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.listOfOperands.<anonymous>' call
|
|
998
|
-
var tmp$ret$0 = ensureNotNull(item).accept($this);
|
|
999
|
-
destination.o(tmp$ret$0);
|
|
1000
|
-
}
|
|
1001
|
-
return destination;
|
|
1002
|
-
}
|
|
1003
|
-
function listOfOperators($this, ctx) {
|
|
1004
|
-
// Inline function 'kotlin.collections.map' call
|
|
1005
|
-
var this_0 = ctx.operators;
|
|
1006
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
1007
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
1008
|
-
var inductionVariable = 0;
|
|
1009
|
-
var last = this_0.length;
|
|
1010
|
-
while (inductionVariable < last) {
|
|
1011
|
-
var item = this_0[inductionVariable];
|
|
1012
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
1013
|
-
// Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.listOfOperators.<anonymous>' call
|
|
1014
|
-
var tmp$ret$0 = item.symbol.text;
|
|
1015
|
-
destination.o(tmp$ret$0);
|
|
1016
|
-
}
|
|
1017
|
-
return destination;
|
|
1018
|
-
}
|
|
1019
|
-
function visitInfixRightAssociativeExpression($this, ctx) {
|
|
1020
|
-
return infixRight($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
|
|
1021
|
-
}
|
|
1022
|
-
function visitInfixLeftAssociativeExpression($this, ctx) {
|
|
1023
|
-
return infixLeft($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
|
|
1024
|
-
}
|
|
1025
|
-
function flatten($this, outers) {
|
|
1026
|
-
// Inline function 'kotlin.sequences.asSequence' call
|
|
1027
|
-
var tmp = outers;
|
|
1028
|
-
return flatMap(tmp, PrologVisitor$flatten$lambda($this));
|
|
1029
|
-
}
|
|
1030
|
-
function flatten_0($this, outers) {
|
|
1031
|
-
return toList_0(flatten($this, asSequence(outers)));
|
|
1032
|
-
}
|
|
1033
|
-
function PrologVisitor$visitExpression$ref($boundThis) {
|
|
1034
|
-
var l = function (p0) {
|
|
1035
|
-
return $boundThis.c3j(p0);
|
|
1036
|
-
};
|
|
1037
|
-
l.callableName = 'visitExpression';
|
|
1038
|
-
return l;
|
|
1039
|
-
}
|
|
1040
|
-
function PrologVisitor$flatten$lambda(this$0) {
|
|
1041
|
-
return function (it) {
|
|
1042
|
-
return plus_1(sequenceOf([it]), flatten(this$0, asSequence_0(it.outers)));
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
function PrologVisitor(scope) {
|
|
1046
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
1047
|
-
PrologParserVisitor.call(this);
|
|
1048
|
-
this.b3j_1 = scope;
|
|
1049
|
-
}
|
|
1050
|
-
protoOf(PrologVisitor).d3j = function (ctx) {
|
|
1051
|
-
return this.e3j(ctx.term());
|
|
1052
|
-
};
|
|
1053
|
-
protoOf(PrologVisitor).visitSingletonTerm = function (ctx) {
|
|
1054
|
-
return this.d3j(ctx);
|
|
1055
|
-
};
|
|
1056
|
-
protoOf(PrologVisitor).f3j = function (ctx) {
|
|
1057
|
-
return this.c3j(ctx.expression());
|
|
1058
|
-
};
|
|
1059
|
-
protoOf(PrologVisitor).visitSingletonExpression = function (ctx) {
|
|
1060
|
-
return this.f3j(ctx);
|
|
1061
|
-
};
|
|
1062
|
-
protoOf(PrologVisitor).g3j = function (ctx) {
|
|
1063
|
-
return termToClause(ctx.expression().accept(this), null, ensureNotNull(ctx.start).line, ensureNotNull(ctx.start).column);
|
|
1064
|
-
};
|
|
1065
|
-
protoOf(PrologVisitor).visitClause = function (ctx) {
|
|
1066
|
-
return this.g3j(ctx);
|
|
1067
|
-
};
|
|
1068
|
-
protoOf(PrologVisitor).c3j = function (ctx) {
|
|
1069
|
-
var tmp;
|
|
1070
|
-
if (ctx.isTerm) {
|
|
1071
|
-
tmp = this.e3j(ensureNotNull(ctx.left));
|
|
1072
|
-
} else if (contains(Associativity.INFIX, ctx.associativity)) {
|
|
1073
|
-
tmp = visitInfixExpression(this, ctx);
|
|
1074
|
-
} else if (contains(Associativity.POSTFIX, ctx.associativity)) {
|
|
1075
|
-
tmp = visitPostfixExpression(this, ctx);
|
|
1076
|
-
} else if (contains(Associativity.PREFIX, ctx.associativity)) {
|
|
1077
|
-
tmp = visitPrefixExpression(this, ctx);
|
|
1078
|
-
} else {
|
|
1079
|
-
throw IllegalArgumentException_init_$Create$('Associativity unknown: ' + ctx.associativity + ' INFIX=' + Associativity.INFIX + ' PREFIX=' + Associativity.PREFIX + ' POSTFIX=' + Associativity.POSTFIX);
|
|
1080
|
-
}
|
|
1081
|
-
return handleOuters(this, tmp, flatten_0(this, asList(ctx.outers)));
|
|
1082
|
-
};
|
|
1083
|
-
protoOf(PrologVisitor).visitExpression = function (ctx) {
|
|
1084
|
-
return this.c3j(ctx);
|
|
1085
|
-
};
|
|
1086
|
-
protoOf(PrologVisitor).e3j = function (ctx) {
|
|
1087
|
-
var tmp;
|
|
1088
|
-
if (ctx.isExpr) {
|
|
1089
|
-
tmp = this.c3j(ctx.expression());
|
|
1090
|
-
} else {
|
|
1091
|
-
var tmp_0 = ctx.children[0].accept(this);
|
|
1092
|
-
tmp = (!(tmp_0 == null) ? isInterface(tmp_0, Term) : false) ? tmp_0 : THROW_CCE();
|
|
1093
|
-
}
|
|
1094
|
-
return tmp;
|
|
1095
|
-
};
|
|
1096
|
-
protoOf(PrologVisitor).visitTerm = function (ctx) {
|
|
1097
|
-
return this.e3j(ctx);
|
|
1098
|
-
};
|
|
1099
|
-
protoOf(PrologVisitor).h3j = function (ctx) {
|
|
1100
|
-
var value = parseInteger_0(this, ctx);
|
|
1101
|
-
return Companion_getInstance_2().ofBigInteger(value);
|
|
1102
|
-
};
|
|
1103
|
-
protoOf(PrologVisitor).visitInteger = function (ctx) {
|
|
1104
|
-
return this.h3j(ctx);
|
|
1105
|
-
};
|
|
1106
|
-
protoOf(PrologVisitor).i3j = function (ctx) {
|
|
1107
|
-
var tmp = ctx.children[0].accept(this);
|
|
1108
|
-
return (!(tmp == null) ? isInterface(tmp, Term) : false) ? tmp : THROW_CCE();
|
|
1109
|
-
};
|
|
1110
|
-
protoOf(PrologVisitor).visitNumber = function (ctx) {
|
|
1111
|
-
return this.i3j(ctx);
|
|
1112
|
-
};
|
|
1113
|
-
protoOf(PrologVisitor).j3j = function (ctx) {
|
|
1114
|
-
var raw = ctx.value.text;
|
|
1115
|
-
if (!(ctx.sign == null)) {
|
|
1116
|
-
var tmp0_safe_receiver = ctx.sign;
|
|
1117
|
-
raw = plus(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text, raw);
|
|
1118
|
-
}
|
|
1119
|
-
var tmp;
|
|
1120
|
-
try {
|
|
1121
|
-
tmp = Companion_getInstance_3().parse(raw);
|
|
1122
|
-
} catch ($p) {
|
|
1123
|
-
var tmp_0;
|
|
1124
|
-
if ($p instanceof NumberFormatException) {
|
|
1125
|
-
var notAFloating = $p;
|
|
1126
|
-
throw parseException(ctx.value, 'Invalid real number format: ' + ctx.value.text);
|
|
1127
|
-
} else {
|
|
1128
|
-
throw $p;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
return tmp;
|
|
1132
|
-
};
|
|
1133
|
-
protoOf(PrologVisitor).visitReal = function (ctx) {
|
|
1134
|
-
return this.j3j(ctx);
|
|
1135
|
-
};
|
|
1136
|
-
protoOf(PrologVisitor).k3j = function (ctx) {
|
|
1137
|
-
var tmp;
|
|
1138
|
-
if (ctx.isAnonymous) {
|
|
1139
|
-
tmp = this.b3j_1.anonymous();
|
|
1140
|
-
} else {
|
|
1141
|
-
tmp = this.b3j_1.varOf(ctx.value.text);
|
|
1142
|
-
}
|
|
1143
|
-
return tmp;
|
|
1144
|
-
};
|
|
1145
|
-
protoOf(PrologVisitor).visitVariable = function (ctx) {
|
|
1146
|
-
return this.k3j(ctx);
|
|
1147
|
-
};
|
|
1148
|
-
protoOf(PrologVisitor).l3j = function (ctx) {
|
|
1149
|
-
var tmp;
|
|
1150
|
-
if (ctx.isList) {
|
|
1151
|
-
tmp = this.b3j_1.logicListOf([]);
|
|
1152
|
-
} else if (ctx.isBlock) {
|
|
1153
|
-
tmp = this.b3j_1.blockOf([]);
|
|
1154
|
-
} else if (ctx.arity === 0) {
|
|
1155
|
-
tmp = this.b3j_1.atomOf(ctx.functor.text);
|
|
1156
|
-
} else {
|
|
1157
|
-
var tmp_0 = ctx.functor.text;
|
|
1158
|
-
var tmp_1 = asSequence_0(ctx.args);
|
|
1159
|
-
tmp = this.b3j_1.structOfSequence(tmp_0, map(tmp_1, PrologVisitor$visitExpression$ref(this)));
|
|
1160
|
-
}
|
|
1161
|
-
return tmp;
|
|
1162
|
-
};
|
|
1163
|
-
protoOf(PrologVisitor).visitStructure = function (ctx) {
|
|
1164
|
-
return this.l3j(ctx);
|
|
1165
|
-
};
|
|
1166
|
-
protoOf(PrologVisitor).m3j = function (ctx) {
|
|
1167
|
-
// Inline function 'kotlin.collections.map' call
|
|
1168
|
-
var this_0 = ctx.items;
|
|
1169
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
1170
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
1171
|
-
var inductionVariable = 0;
|
|
1172
|
-
var last = this_0.length;
|
|
1173
|
-
while (inductionVariable < last) {
|
|
1174
|
-
var item = this_0[inductionVariable];
|
|
1175
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
1176
|
-
var tmp$ret$0 = this.c3j(item);
|
|
1177
|
-
destination.o(tmp$ret$0);
|
|
1178
|
-
}
|
|
1179
|
-
var terms = destination;
|
|
1180
|
-
var tmp;
|
|
1181
|
-
if (ctx.hasTail) {
|
|
1182
|
-
var tmp0_safe_receiver = ctx.tail;
|
|
1183
|
-
tmp = this.b3j_1.h12(terms, tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept(this));
|
|
1184
|
-
} else {
|
|
1185
|
-
tmp = this.b3j_1.logicListOfIterable(terms);
|
|
1186
|
-
}
|
|
1187
|
-
return tmp;
|
|
1188
|
-
};
|
|
1189
|
-
protoOf(PrologVisitor).visitList = function (ctx) {
|
|
1190
|
-
return this.m3j(ctx);
|
|
1191
|
-
};
|
|
1192
|
-
protoOf(PrologVisitor).n3j = function (ctx) {
|
|
1193
|
-
var tmp;
|
|
1194
|
-
if (ctx.length === 1) {
|
|
1195
|
-
tmp = this.b3j_1.blockOf([ctx.items[0].accept(this)]);
|
|
1196
|
-
} else {
|
|
1197
|
-
// Inline function 'kotlin.collections.map' call
|
|
1198
|
-
var this_0 = ctx.items;
|
|
1199
|
-
// Inline function 'kotlin.collections.mapTo' call
|
|
1200
|
-
var destination = ArrayList_init_$Create$(this_0.length);
|
|
1201
|
-
var inductionVariable = 0;
|
|
1202
|
-
var last = this_0.length;
|
|
1203
|
-
while (inductionVariable < last) {
|
|
1204
|
-
var item = this_0[inductionVariable];
|
|
1205
|
-
inductionVariable = inductionVariable + 1 | 0;
|
|
1206
|
-
var tmp$ret$0 = this.c3j(item);
|
|
1207
|
-
destination.o(tmp$ret$0);
|
|
1208
|
-
}
|
|
1209
|
-
tmp = this.b3j_1.blockOfIterable(destination);
|
|
1210
|
-
}
|
|
1211
|
-
return tmp;
|
|
1212
|
-
};
|
|
1213
|
-
protoOf(PrologVisitor).visitBlock = function (ctx) {
|
|
1214
|
-
return this.n3j(ctx);
|
|
1215
|
-
};
|
|
1216
|
-
function termParserWithOperators(operators, scope) {
|
|
1217
|
-
scope = scope === VOID ? Companion_instance.empty() : scope;
|
|
1218
|
-
return new TermParserImpl(scope, operators);
|
|
1219
|
-
}
|
|
1220
|
-
function TermParserImpl(scope, defaultOperatorSet) {
|
|
1221
|
-
this.o3j_1 = scope;
|
|
1222
|
-
this.p3j_1 = defaultOperatorSet;
|
|
1223
|
-
}
|
|
1224
|
-
protoOf(TermParserImpl).r3i = function () {
|
|
1225
|
-
return this.p3j_1;
|
|
1226
|
-
};
|
|
1227
|
-
protoOf(TermParserImpl).q3j = function (input, operators) {
|
|
1228
|
-
return PrologParserFactory_instance.x3i(input, operators).accept(new PrologVisitor(this.o3j_1));
|
|
1229
|
-
};
|
|
1230
|
-
protoOf(TermParserImpl).parseTermWithOperators = function (input, operators) {
|
|
1231
|
-
return this.q3j(input, operators);
|
|
1232
|
-
};
|
|
1233
|
-
//region block: post-declaration
|
|
1234
|
-
protoOf(TermParserImpl).parseTerm = parseTerm;
|
|
1235
|
-
protoOf(TermParserImpl).parseStructWithOperators = parseStructWithOperators;
|
|
1236
|
-
protoOf(TermParserImpl).parseStruct = parseStruct;
|
|
1237
|
-
protoOf(TermParserImpl).parseConstantWithOperators = parseConstantWithOperators;
|
|
1238
|
-
protoOf(TermParserImpl).parseConstant = parseConstant;
|
|
1239
|
-
protoOf(TermParserImpl).parseVarWithOperators = parseVarWithOperators;
|
|
1240
|
-
protoOf(TermParserImpl).parseVar = parseVar;
|
|
1241
|
-
protoOf(TermParserImpl).parseAtomWithOperators = parseAtomWithOperators;
|
|
1242
|
-
protoOf(TermParserImpl).parseAtom = parseAtom;
|
|
1243
|
-
protoOf(TermParserImpl).parseNumericWithOperators = parseNumericWithOperators;
|
|
1244
|
-
protoOf(TermParserImpl).parseNumeric = parseNumeric;
|
|
1245
|
-
protoOf(TermParserImpl).parseIntegerWithOperators = parseIntegerWithOperators;
|
|
1246
|
-
protoOf(TermParserImpl).parseInteger = parseInteger;
|
|
1247
|
-
protoOf(TermParserImpl).parseRealWithOperators = parseRealWithOperators;
|
|
1248
|
-
protoOf(TermParserImpl).parseReal = parseReal;
|
|
1249
|
-
protoOf(TermParserImpl).parseClauseWithOperators = parseClauseWithOperators;
|
|
1250
|
-
protoOf(TermParserImpl).parseClause = parseClause;
|
|
1251
|
-
protoOf(TermParserImpl).parseRuleWithOperators = parseRuleWithOperators;
|
|
1252
|
-
protoOf(TermParserImpl).parseRule = parseRule;
|
|
1253
|
-
protoOf(TermParserImpl).parseFactWithOperators = parseFactWithOperators;
|
|
1254
|
-
protoOf(TermParserImpl).parseFact = parseFact;
|
|
1255
|
-
protoOf(TermParserImpl).parseDirectiveWithOperators = parseDirectiveWithOperators;
|
|
1256
|
-
protoOf(TermParserImpl).parseDirective = parseDirective;
|
|
1257
|
-
//endregion
|
|
1258
|
-
//region block: init
|
|
1259
|
-
Companion_instance_1 = new Companion();
|
|
1260
|
-
Companion_instance_2 = new Companion_0();
|
|
1261
|
-
PrologParserFactory_instance = new PrologParserFactory();
|
|
1262
|
-
//endregion
|
|
1263
|
-
//region block: exports
|
|
1264
|
-
_.$_$ = _.$_$ || {};
|
|
1265
|
-
_.$_$.a = PrologParserFactory_instance;
|
|
1266
|
-
_.$_$.b = ParseException;
|
|
1267
|
-
_.$_$.c = PrologVisitor;
|
|
1268
|
-
_.$_$.d = parseStruct_0;
|
|
1269
|
-
_.$_$.e = parseStructWithOperators_0;
|
|
1270
|
-
_.$_$.f = termToClause;
|
|
1271
11
|
//endregion
|
|
1272
12
|
return _;
|
|
1273
13
|
}));
|