@tuprolog/arg2p-core 0.7.1 → 0.7.2

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-parser-core.js CHANGED
@@ -1,13 +1,1015 @@
1
1
  (function (root, factory) {
2
2
  if (typeof define === 'function' && define.amd)
3
- define(['exports'], factory);
3
+ define(['exports', '@tuprolog/parser-utils', 'antlr4', 'antlr4/src/antlr4/error', 'antlr4/src/antlr4/atn', './kotlin-kotlin-stdlib-js-ir.js', './2p-core.js', './2p-parser-js.js', './kt-math.js'], factory);
4
4
  else if (typeof exports === 'object')
5
- factory(module.exports);
6
- else
7
- root['2p-parser-core'] = factory(typeof this['2p-parser-core'] === 'undefined' ? {} : this['2p-parser-core']);
8
- }(this, function (_) {
5
+ factory(module.exports, require('@tuprolog/parser-utils'), require('antlr4'), require('antlr4/src/antlr4/error'), require('antlr4/src/antlr4/atn'), require('./kotlin-kotlin-stdlib-js-ir.js'), require('./2p-core.js'), require('./2p-parser-js.js'), require('./kt-math.js'));
6
+ else {
7
+ if (typeof this['@tuprolog/parser-utils'] === 'undefined') {
8
+ throw new Error("Error loading module '2p-parser-core'. Its dependency '@tuprolog/parser-utils' was not found. Please, check whether '@tuprolog/parser-utils' is loaded prior to '2p-parser-core'.");
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-js-ir'] === 'undefined') {
20
+ throw new Error("Error loading module '2p-parser-core'. Its dependency 'kotlin-kotlin-stdlib-js-ir' was not found. Please, check whether 'kotlin-kotlin-stdlib-js-ir' 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-js-ir'], 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) {
9
34
  '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.$_$.s9;
48
+ var captureStack = kotlin_kotlin.$_$.p4;
49
+ var protoOf = kotlin_kotlin.$_$.q5;
50
+ var classMeta = kotlin_kotlin.$_$.u4;
51
+ var setMetadataFor = kotlin_kotlin.$_$.r5;
52
+ var TuPrologException = kotlin_it_unibo_tuprolog_core.$_$.x;
53
+ var TuPrologException_init_$Init$ = kotlin_it_unibo_tuprolog_core.$_$.b;
54
+ var ensureNotNull = kotlin_kotlin.$_$.i9;
55
+ var replace = kotlin_kotlin.$_$.i8;
56
+ var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.c1;
57
+ var Char = kotlin_kotlin.$_$.u8;
58
+ var Clause = kotlin_it_unibo_tuprolog_core.$_$.b1;
59
+ var getKClass = kotlin_kotlin.$_$.c;
60
+ var Companion_getInstance = kotlin_it_unibo_tuprolog_core.$_$.j;
61
+ var Struct = kotlin_it_unibo_tuprolog_core.$_$.l1;
62
+ var isInterface = kotlin_kotlin.$_$.f5;
63
+ var Unit_getInstance = kotlin_kotlin.$_$.o1;
64
+ var objectMeta = kotlin_kotlin.$_$.p5;
65
+ var THROW_CCE = kotlin_kotlin.$_$.f9;
66
+ var Atom = kotlin_it_unibo_tuprolog_core.$_$.a1;
67
+ var contains = kotlin_kotlin.$_$.f2;
68
+ var Directive = kotlin_it_unibo_tuprolog_core.$_$.d1;
69
+ var Numeric = kotlin_it_unibo_tuprolog_core.$_$.i1;
70
+ var Companion_getInstance_0 = kotlin_it_unibo_tuprolog_core.$_$.g;
71
+ var map = kotlin_kotlin.$_$.h7;
72
+ var Operator = kotlin_it_unibo_tuprolog_core.$_$.z;
73
+ var List = kotlin_it_unibo_tuprolog_core.$_$.h1;
74
+ var toString = kotlin_kotlin.$_$.v5;
75
+ var coerceAtLeast = kotlin_kotlin.$_$.g6;
76
+ var isRecognitionException = kotlin_it_unibo_tuprolog_parser_js.$_$.b;
77
+ var isParseCancellationException = kotlin_it_unibo_tuprolog_parser_js.$_$.a;
78
+ var generateSequence = kotlin_kotlin.$_$.b7;
79
+ var takeWhile = kotlin_kotlin.$_$.p7;
80
+ var to = kotlin_kotlin.$_$.r9;
81
+ var Companion_getInstance_1 = kotlin_io_github_gciatto_kt_math.$_$.e;
82
+ var charSequenceGet = kotlin_kotlin.$_$.s4;
83
+ var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.f1;
84
+ var contains_0 = kotlin_kotlin.$_$.b8;
85
+ var plus = kotlin_kotlin.$_$.m9;
86
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.d;
87
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.s;
88
+ var listOf = kotlin_kotlin.$_$.a3;
89
+ var asList = kotlin_kotlin.$_$.x1;
90
+ var plus_0 = kotlin_kotlin.$_$.s3;
91
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.d2;
92
+ var toList = kotlin_kotlin.$_$.c4;
93
+ var flatMap = kotlin_kotlin.$_$.z6;
94
+ var asSequence = kotlin_kotlin.$_$.b2;
95
+ var toList_0 = kotlin_kotlin.$_$.t7;
96
+ var sequenceOf = kotlin_kotlin.$_$.m7;
97
+ var asSequence_0 = kotlin_kotlin.$_$.c2;
98
+ var plus_1 = kotlin_kotlin.$_$.l7;
99
+ var Companion_getInstance_2 = kotlin_it_unibo_tuprolog_core.$_$.q;
100
+ var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.q;
101
+ var Term = kotlin_it_unibo_tuprolog_core.$_$.j2;
102
+ var Companion_getInstance_3 = kotlin_it_unibo_tuprolog_core.$_$.l;
103
+ var Companion_getInstance_4 = kotlin_it_unibo_tuprolog_core.$_$.o;
104
+ var NumberFormatException = kotlin_kotlin.$_$.c9;
105
+ //endregion
10
106
  //region block: pre-declaration
107
+ setMetadataFor(ParseException, 'ParseException', classMeta, TuPrologException);
108
+ setMetadataFor(InvalidTermTypeException, 'InvalidTermTypeException', classMeta, ParseException);
109
+ setMetadataFor(Companion, 'Companion', objectMeta);
110
+ setMetadataFor(DynamicOpListener, 'DynamicOpListener', classMeta, PrologParserListener);
111
+ setMetadataFor(PrologParserFactory$newErrorListener$1, VOID, classMeta);
112
+ setMetadataFor(PrologParserFactory, 'PrologParserFactory', objectMeta);
113
+ setMetadataFor(PrologVisitor, 'PrologVisitor', classMeta, PrologParserVisitor);
114
+ //endregion
115
+ function InvalidTermTypeException(input, term, type, offendingSymbol, line, column, message, throwable) {
116
+ var tmp;
117
+ if (offendingSymbol === VOID) {
118
+ var tmp0_elvis_lhs = (!(input == null) ? typeof input === 'string' : false) ? input : null;
119
+ tmp = tmp0_elvis_lhs == null ? term.toString() : tmp0_elvis_lhs;
120
+ } else {
121
+ tmp = offendingSymbol;
122
+ }
123
+ offendingSymbol = tmp;
124
+ line = line === VOID ? 1 : line;
125
+ column = column === VOID ? 1 : column;
126
+ message = message === VOID ? 'Expected ' + type.xc() + ', got: ' + offendingSymbol : message;
127
+ throwable = throwable === VOID ? null : throwable;
128
+ ParseException.call(this, input, offendingSymbol, line, column, message, throwable);
129
+ captureStack(this, InvalidTermTypeException);
130
+ this.l33_1 = term;
131
+ this.m33_1 = type;
132
+ }
133
+ function ParseException(input, offendingSymbol, line, column, message, throwable) {
134
+ TuPrologException_init_$Init$(message, throwable, this);
135
+ captureStack(this, ParseException);
136
+ this.input = input;
137
+ this.offendingSymbol = offendingSymbol;
138
+ this.line = line;
139
+ this.column = column;
140
+ this.clauseIndex = -1;
141
+ }
142
+ protoOf(ParseException).n33 = function (_set____db54di) {
143
+ this.input = _set____db54di;
144
+ };
145
+ protoOf(ParseException).o33 = function () {
146
+ return this.input;
147
+ };
148
+ protoOf(ParseException).p33 = function (_set____db54di) {
149
+ this.offendingSymbol = _set____db54di;
150
+ };
151
+ protoOf(ParseException).q33 = function () {
152
+ return this.offendingSymbol;
153
+ };
154
+ protoOf(ParseException).r33 = function (_set____db54di) {
155
+ this.line = _set____db54di;
156
+ };
157
+ protoOf(ParseException).s33 = function () {
158
+ return this.line;
159
+ };
160
+ protoOf(ParseException).t33 = function (_set____db54di) {
161
+ this.column = _set____db54di;
162
+ };
163
+ protoOf(ParseException).u33 = function () {
164
+ return this.column;
165
+ };
166
+ protoOf(ParseException).v33 = function (_set____db54di) {
167
+ this.clauseIndex = _set____db54di;
168
+ };
169
+ protoOf(ParseException).w33 = function () {
170
+ return this.clauseIndex;
171
+ };
172
+ protoOf(ParseException).toString = function () {
173
+ 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)) + new Char(_Char___init__impl__6a9atx(125));
174
+ };
175
+ function termToClause(_this__u8e3s4, source, line, column) {
176
+ source = source === VOID ? null : source;
177
+ line = line === VOID ? 0 : line;
178
+ column = column === VOID ? 0 : column;
179
+ var tmp0_subject = _this__u8e3s4;
180
+ var tmp;
181
+ if (isInterface(tmp0_subject, Clause)) {
182
+ tmp = _this__u8e3s4;
183
+ } else {
184
+ if (isInterface(tmp0_subject, Struct)) {
185
+ tmp = Companion_getInstance().of(_this__u8e3s4);
186
+ } else {
187
+ throw new InvalidTermTypeException(source, _this__u8e3s4, getKClass(Clause), VOID, line, column);
188
+ }
189
+ }
190
+ return tmp;
191
+ }
192
+ function toAssociativity(_this__u8e3s4) {
193
+ return _this__u8e3s4.toString();
194
+ }
195
+ function DynamicOpListener$Companion$of$lambda($this$$receiver, it) {
196
+ return Unit_getInstance();
197
+ }
198
+ function onOperatorDefined($this, operator) {
199
+ $this.x33_1.addOperator(operator.l1f_1, toAssociativity(operator.m1f_1), operator.n1f_1);
200
+ $this.y33_1($this.x33_1, operator);
201
+ }
202
+ function Companion() {
203
+ Companion_instance = this;
204
+ }
205
+ protoOf(Companion).z33 = function (parser) {
206
+ return new DynamicOpListener(parser, DynamicOpListener$Companion$of$lambda);
207
+ };
208
+ var Companion_instance;
209
+ function Companion_getInstance_5() {
210
+ if (Companion_instance == null)
211
+ new Companion();
212
+ return Companion_instance;
213
+ }
214
+ function DynamicOpListener$exitClause$lambda(it) {
215
+ return isInterface(it, Atom) ? it : THROW_CCE();
216
+ }
217
+ function DynamicOpListener(parser, operatorDefinedCallback) {
218
+ Companion_getInstance_5();
219
+ PrologParserListener.call(this);
220
+ this.x33_1 = parser;
221
+ this.y33_1 = operatorDefinedCallback;
222
+ }
223
+ protoOf(DynamicOpListener).a34 = function (ctx) {
224
+ var expr = ctx.expression();
225
+ if (ctx.exception != null) {
226
+ return Unit_getInstance();
227
+ }
228
+ var tmp;
229
+ var tmp_0;
230
+ if (!(expr._op == null)) {
231
+ var tmp0_safe_receiver = expr._op;
232
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.symbol;
233
+ tmp_0 = ':-' === (tmp1_safe_receiver == null ? null : tmp1_safe_receiver.text);
234
+ } else {
235
+ tmp_0 = false;
236
+ }
237
+ if (tmp_0) {
238
+ tmp = contains(Associativity.PREFIX, expr.associativity);
239
+ } else {
240
+ tmp = false;
241
+ }
242
+ if (tmp) {
243
+ var tmp_1 = ctx.accept(new PrologVisitor());
244
+ var directive = isInterface(tmp_1, Directive) ? tmp_1 : THROW_CCE();
245
+ var op = directive.mv();
246
+ var tmp_2;
247
+ var tmp_3;
248
+ var tmp_4;
249
+ var tmp_5;
250
+ var tmp_6;
251
+ if (isInterface(op, Struct)) {
252
+ tmp_6 = op.lt() === 3;
253
+ } else {
254
+ tmp_6 = false;
255
+ }
256
+ if (tmp_6) {
257
+ tmp_5 = op.rt() === 'op';
258
+ } else {
259
+ tmp_5 = false;
260
+ }
261
+ if (tmp_5) {
262
+ var tmp_7 = op.get(0);
263
+ tmp_4 = isInterface(tmp_7, Numeric);
264
+ } else {
265
+ tmp_4 = false;
266
+ }
267
+ if (tmp_4) {
268
+ var tmp_8 = op.get(1);
269
+ tmp_3 = isInterface(tmp_8, Atom);
270
+ } else {
271
+ tmp_3 = false;
272
+ }
273
+ if (tmp_3) {
274
+ tmp_2 = op.ku();
275
+ } else {
276
+ tmp_2 = false;
277
+ }
278
+ if (tmp_2) {
279
+ var tmp$ret$1;
280
+ // Inline function 'kotlin.math.min' call
281
+ var tmp$ret$0;
282
+ // Inline function 'kotlin.math.max' call
283
+ var tmp_9 = op.get(0);
284
+ var tmp0_max = (isInterface(tmp_9, Numeric) ? tmp_9 : THROW_CCE()).sw().toInt();
285
+ tmp$ret$0 = Math.max(0, tmp0_max);
286
+ var tmp1_min = tmp$ret$0;
287
+ tmp$ret$1 = Math.min(1200, tmp1_min);
288
+ var priority = tmp$ret$1;
289
+ var specifier = Companion_getInstance_0().fromTerm(op.get(1));
290
+ var operator = op.get(2);
291
+ if (isInterface(operator, Atom)) {
292
+ onOperatorDefined(this, new Operator(operator.p2(), specifier, priority));
293
+ } else {
294
+ if (isInterface(operator, List)) {
295
+ var tmp$ret$3;
296
+ $l$block: {
297
+ // Inline function 'kotlin.sequences.all' call
298
+ var tmp2_all = operator.hs();
299
+ var tmp0_iterator = tmp2_all.j();
300
+ while (tmp0_iterator.m()) {
301
+ var element = tmp0_iterator.n();
302
+ var tmp$ret$2;
303
+ // Inline function 'it.unibo.tuprolog.core.parsing.DynamicOpListener.exitClause.<anonymous>' call
304
+ tmp$ret$2 = isInterface(element, Atom);
305
+ if (!tmp$ret$2) {
306
+ tmp$ret$3 = false;
307
+ break $l$block;
308
+ }
309
+ }
310
+ tmp$ret$3 = true;
311
+ }
312
+ if (tmp$ret$3) {
313
+ var tmp_10 = operator.hs();
314
+ var tmp2_iterator = map(tmp_10, DynamicOpListener$exitClause$lambda).j();
315
+ while (tmp2_iterator.m()) {
316
+ var it = tmp2_iterator.n();
317
+ onOperatorDefined(this, new Operator(it.p2(), specifier, priority));
318
+ }
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }
324
+ };
325
+ protoOf(DynamicOpListener).exitClause = function (ctx) {
326
+ return this.a34(ctx);
327
+ };
328
+ function parseException(token, message) {
329
+ return new ParseException(null, token.text, token.line, token.column, message, null);
330
+ }
331
+ function symbolToString($this, obj) {
332
+ var tmp;
333
+ if (obj instanceof Token) {
334
+ tmp = obj.text;
335
+ } else {
336
+ tmp = toString(obj);
337
+ }
338
+ return tmp;
339
+ }
340
+ function newErrorListener($this, whileParsing) {
341
+ return new PrologParserFactory$newErrorListener$1(whileParsing);
342
+ }
343
+ function parseClause($this, parserAndErrorStrategy, source) {
344
+ var mark = -1;
345
+ var index = -1;
346
+ var parser = parserAndErrorStrategy.f4_1;
347
+ var tmp;
348
+ try {
349
+ mark = parser.getTokenStream().mark();
350
+ index = coerceAtLeast(parser.getTokenStream().index, 0);
351
+ tmp = parser.optClause();
352
+ } catch ($p) {
353
+ var tmp_0;
354
+ {
355
+ var e = $p;
356
+ var tmp_1;
357
+ if (isParseCancellationException(e) ? parser._interp.predictionMode === PredictionMode.SLL : false) {
358
+ parser.getTokenStream().seek(index);
359
+ parser._interp.predictionMode = PredictionMode.LL;
360
+ parser._errHandler = parserAndErrorStrategy.g4_1;
361
+ parser.addErrorListener(newErrorListener($this, source));
362
+ tmp_1 = parseClause($this, parserAndErrorStrategy, source);
363
+ } else if (e.clause !== null ? isRecognitionException(e.cause) : false) {
364
+ var tmp_2 = e.cause;
365
+ throw tmp_2 instanceof RecognitionException ? tmp_2 : THROW_CCE();
366
+ } else {
367
+ throw e instanceof Error ? e : THROW_CCE();
368
+ }
369
+ tmp_0 = tmp_1;
370
+ }
371
+ tmp = tmp_0;
372
+ }
373
+ finally {
374
+ parser.getTokenStream().release(mark);
375
+ }
376
+ return tmp;
377
+ }
378
+ function parseClauses($this, parser, source) {
379
+ var tmp = generateSequence(0, PrologParserFactory$parseClauses$lambda);
380
+ var tmp_0 = map(tmp, PrologParserFactory$parseClauses$lambda_0(parser, source));
381
+ var tmp_1 = takeWhile(tmp_0, PrologParserFactory$parseClauses$lambda_1);
382
+ return map(tmp_1, PrologParserFactory$parseClauses$lambda_2);
383
+ }
384
+ function PrologParserFactory$newErrorListener$1($whileParsing) {
385
+ this.b34_1 = $whileParsing;
386
+ }
387
+ protoOf(PrologParserFactory$newErrorListener$1).syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
388
+ if (recognizer instanceof PrologParser) {
389
+ recognizer.removeParseListeners();
390
+ }
391
+ throw new ParseException(this.b34_1, symbolToString(this, offendingSymbol), line, column + 1 | 0, msg, e);
392
+ };
393
+ function PrologParserFactory$parseClauses$lambda(it) {
394
+ return it + 1 | 0;
395
+ }
396
+ function PrologParserFactory$parseClauses$lambda_0($parser, $source) {
397
+ return function (it) {
398
+ var tmp;
399
+ try {
400
+ tmp = parseClause(PrologParserFactory_getInstance(), $parser, $source);
401
+ } catch ($p) {
402
+ var tmp_0;
403
+ if ($p instanceof ParseException) {
404
+ var e = $p;
405
+ e.clauseIndex = it;
406
+ throw e;
407
+ } else {
408
+ throw $p;
409
+ }
410
+ tmp = tmp_0;
411
+ }
412
+ return tmp;
413
+ };
414
+ }
415
+ function PrologParserFactory$parseClauses$lambda_1(it) {
416
+ return !it.isOver;
417
+ }
418
+ function PrologParserFactory$parseClauses$lambda_2(it) {
419
+ return it.clause();
420
+ }
421
+ function PrologParserFactory() {
422
+ PrologParserFactory_instance = this;
423
+ }
424
+ protoOf(PrologParserFactory).c34 = function (source, withOperators) {
425
+ var parser = this.d34(source, withOperators);
426
+ return parseClauses(this, parser, source);
427
+ };
428
+ protoOf(PrologParserFactory).d34 = function (source, operators) {
429
+ var stream = new InputStream(source);
430
+ var lexer = new PrologLexer(stream);
431
+ lexer.removeErrorListeners();
432
+ var tokenStream = new CommonTokenStream(lexer);
433
+ var parser = new PrologParser(tokenStream);
434
+ parser.removeErrorListeners();
435
+ var originalErrorStrategy = parser._errHandler;
436
+ parser._errHandler = new BailErrorStrategy();
437
+ parser._interp.predictionMode = PredictionMode.SLL;
438
+ return to(this.e34(parser, operators), originalErrorStrategy);
439
+ };
440
+ protoOf(PrologParserFactory).e34 = function (prologParser, operators) {
441
+ // Inline function 'kotlin.collections.forEach' call
442
+ var tmp0_iterator = operators.j();
443
+ while (tmp0_iterator.m()) {
444
+ var element = tmp0_iterator.n();
445
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologParserFactory.addOperators.<anonymous>' call
446
+ prologParser.addOperator(element.l1f_1, toAssociativity(element.m1f_1), element.n1f_1);
447
+ }
448
+ prologParser.addParseListener(Companion_getInstance_5().z33(prologParser));
449
+ return prologParser;
450
+ };
451
+ var PrologParserFactory_instance;
452
+ function PrologParserFactory_getInstance() {
453
+ if (PrologParserFactory_instance == null)
454
+ new PrologParserFactory();
455
+ return PrologParserFactory_instance;
456
+ }
457
+ function parseInteger($this, ctx) {
458
+ var str = ctx.value.text;
459
+ var base;
460
+ var clean;
461
+ if (ctx.isBin) {
462
+ base = 2;
463
+ var tmp$ret$1;
464
+ // Inline function 'kotlin.text.substring' call
465
+ var tmp$ret$0;
466
+ // Inline function 'kotlin.js.asDynamic' call
467
+ tmp$ret$0 = str;
468
+ tmp$ret$1 = tmp$ret$0.substring(2);
469
+ clean = tmp$ret$1;
470
+ } else if (ctx.isOct) {
471
+ base = 8;
472
+ var tmp$ret$3;
473
+ // Inline function 'kotlin.text.substring' call
474
+ var tmp$ret$2;
475
+ // Inline function 'kotlin.js.asDynamic' call
476
+ tmp$ret$2 = str;
477
+ tmp$ret$3 = tmp$ret$2.substring(2);
478
+ clean = tmp$ret$3;
479
+ } else if (ctx.isHex) {
480
+ base = 16;
481
+ var tmp$ret$5;
482
+ // Inline function 'kotlin.text.substring' call
483
+ var tmp$ret$4;
484
+ // Inline function 'kotlin.js.asDynamic' call
485
+ tmp$ret$4 = str;
486
+ tmp$ret$5 = tmp$ret$4.substring(2);
487
+ clean = tmp$ret$5;
488
+ } else if (ctx.isChar) {
489
+ var tmp$ret$7;
490
+ // Inline function 'kotlin.text.substring' call
491
+ var tmp$ret$6;
492
+ // Inline function 'kotlin.js.asDynamic' call
493
+ tmp$ret$6 = str;
494
+ tmp$ret$7 = tmp$ret$6.substring(2);
495
+ clean = tmp$ret$7;
496
+ if (!(clean.length === 1)) {
497
+ throw parseException(ctx.value, 'Invalid character literal: ' + ctx.value.text);
498
+ }
499
+ var tmp$ret$10;
500
+ // Inline function 'kotlin.with' call
501
+ var tmp = Companion_getInstance_1();
502
+ var tmp$ret$8;
503
+ // Inline function 'kotlin.code' call
504
+ var tmp0__get_code__88qj9g = charSequenceGet(clean, 0);
505
+ tmp$ret$8 = Char__toInt_impl_vasixd(tmp0__get_code__88qj9g);
506
+ var tmp1_with = tmp.of(tmp$ret$8);
507
+ // Inline function 'kotlin.contracts.contract' call
508
+ var tmp$ret$9;
509
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.parseInteger.<anonymous>' call
510
+ var tmp_0;
511
+ var tmp0_safe_receiver = ctx.sign;
512
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text;
513
+ var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : contains_0(tmp1_safe_receiver, '-');
514
+ if (tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs) {
515
+ tmp_0 = tmp1_with.unaryMinus();
516
+ } else {
517
+ tmp_0 = tmp1_with;
518
+ }
519
+ tmp$ret$9 = tmp_0;
520
+ tmp$ret$10 = tmp$ret$9;
521
+ return tmp$ret$10;
522
+ } else {
523
+ base = 10;
524
+ clean = str;
525
+ }
526
+ if (!(ctx.sign == null)) {
527
+ var tmp0_safe_receiver_0 = ctx.sign;
528
+ clean = plus(tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0.text, clean);
529
+ }
530
+ return Companion_getInstance_1().parseWithRadix(clean, base);
531
+ }
532
+ function visitPostfixExpression($this, ctx) {
533
+ var tmp0_safe_receiver = ctx.left;
534
+ var tmp = ensureNotNull(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept($this));
535
+ var tmp$ret$2;
536
+ // Inline function 'kotlin.collections.map' call
537
+ var tmp1_map = ctx.operators;
538
+ var tmp$ret$1;
539
+ // Inline function 'kotlin.collections.mapTo' call
540
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
541
+ var indexedObject = tmp1_map;
542
+ var inductionVariable = 0;
543
+ var last = indexedObject.length;
544
+ while (inductionVariable < last) {
545
+ var item = indexedObject[inductionVariable];
546
+ inductionVariable = inductionVariable + 1 | 0;
547
+ var tmp$ret$0;
548
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitPostfixExpression.<anonymous>' call
549
+ tmp$ret$0 = item.symbol.text;
550
+ tmp0_mapTo.g(tmp$ret$0);
551
+ }
552
+ tmp$ret$1 = tmp0_mapTo;
553
+ tmp$ret$2 = tmp$ret$1;
554
+ return postfix($this, tmp, tmp$ret$2);
555
+ }
556
+ function postfix($this, term, ops) {
557
+ var operator = ops.j();
558
+ var result = $this.f34_1.structOf(operator.n(), [term]);
559
+ while (operator.m()) {
560
+ result = $this.f34_1.structOf(operator.n(), [result]);
561
+ }
562
+ return result;
563
+ }
564
+ function visitPrefixExpression($this, ctx) {
565
+ var tmp = ctx.right[0].accept($this);
566
+ var tmp$ret$2;
567
+ // Inline function 'kotlin.collections.map' call
568
+ var tmp1_map = ctx.operators;
569
+ var tmp$ret$1;
570
+ // Inline function 'kotlin.collections.mapTo' call
571
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
572
+ var indexedObject = tmp1_map;
573
+ var inductionVariable = 0;
574
+ var last = indexedObject.length;
575
+ while (inductionVariable < last) {
576
+ var item = indexedObject[inductionVariable];
577
+ inductionVariable = inductionVariable + 1 | 0;
578
+ var tmp$ret$0;
579
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitPrefixExpression.<anonymous>' call
580
+ tmp$ret$0 = item.symbol.text;
581
+ tmp0_mapTo.g(tmp$ret$0);
582
+ }
583
+ tmp$ret$1 = tmp0_mapTo;
584
+ tmp$ret$2 = tmp$ret$1;
585
+ return prefix($this, tmp, tmp$ret$2);
586
+ }
587
+ function prefix($this, term, ops) {
588
+ var i = ops.p() - 1 | 0;
589
+ var tmp0 = i;
590
+ i = tmp0 - 1 | 0;
591
+ var result = $this.f34_1.structOf(ops.o(tmp0), [term]);
592
+ while (i >= 0) {
593
+ result = $this.f34_1.structOf(ops.o(i), [result]);
594
+ var tmp1 = i;
595
+ i = tmp1 - 1 | 0;
596
+ }
597
+ return result;
598
+ }
599
+ function visitInfixExpression($this, ctx) {
600
+ var tmp0_subject = ctx.associativity;
601
+ var tmp;
602
+ if (tmp0_subject === Associativity.XFY) {
603
+ tmp = visitInfixRightAssociativeExpression($this, ctx);
604
+ } else if (tmp0_subject === Associativity.YFX) {
605
+ tmp = visitInfixLeftAssociativeExpression($this, ctx);
606
+ } else if (tmp0_subject === Associativity.XFX) {
607
+ tmp = visitInfixNonAssociativeExpression($this, ctx);
608
+ } else {
609
+ throw IllegalStateException_init_$Create$();
610
+ }
611
+ return tmp;
612
+ }
613
+ function visitInfixNonAssociativeExpression($this, ctx) {
614
+ var tmp$ret$2;
615
+ // Inline function 'kotlin.collections.map' call
616
+ var tmp1_map = plus_0(listOf(ensureNotNull(ctx.left)), asList(ctx.right));
617
+ var tmp$ret$1;
618
+ // Inline function 'kotlin.collections.mapTo' call
619
+ var tmp0_mapTo = ArrayList_init_$Create$(collectionSizeOrDefault(tmp1_map, 10));
620
+ var tmp0_iterator = tmp1_map.j();
621
+ while (tmp0_iterator.m()) {
622
+ var item = tmp0_iterator.n();
623
+ var tmp$ret$0;
624
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitInfixNonAssociativeExpression.<anonymous>' call
625
+ tmp$ret$0 = item.accept($this);
626
+ tmp0_mapTo.g(tmp$ret$0);
627
+ }
628
+ tmp$ret$1 = tmp0_mapTo;
629
+ tmp$ret$2 = tmp$ret$1;
630
+ var operands = tmp$ret$2;
631
+ var tmp$ret$5;
632
+ // Inline function 'kotlin.collections.map' call
633
+ var tmp3_map = ctx.operators;
634
+ var tmp$ret$4;
635
+ // Inline function 'kotlin.collections.mapTo' call
636
+ var tmp2_mapTo = ArrayList_init_$Create$(tmp3_map.length);
637
+ var indexedObject = tmp3_map;
638
+ var inductionVariable = 0;
639
+ var last = indexedObject.length;
640
+ while (inductionVariable < last) {
641
+ var item_0 = indexedObject[inductionVariable];
642
+ inductionVariable = inductionVariable + 1 | 0;
643
+ var tmp$ret$3;
644
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.visitInfixNonAssociativeExpression.<anonymous>' call
645
+ tmp$ret$3 = item_0.symbol.text;
646
+ tmp2_mapTo.g(tmp$ret$3);
647
+ }
648
+ tmp$ret$4 = tmp2_mapTo;
649
+ tmp$ret$5 = tmp$ret$4;
650
+ var operators = tmp$ret$5;
651
+ return infixNonAssociative($this, operands, operators);
652
+ }
653
+ function infixNonAssociative($this, terms, ops) {
654
+ return $this.f34_1.structOf(ops.o(0), [terms.o(0), terms.o(1)]);
655
+ }
656
+ function handleOuters($this, expression, outers) {
657
+ var result = expression;
658
+ var tmp0_iterator = outers.j();
659
+ while (tmp0_iterator.m()) {
660
+ var o = tmp0_iterator.n();
661
+ var tmp = listOf(result);
662
+ var tmp$ret$2;
663
+ // Inline function 'kotlin.collections.map' call
664
+ var tmp1_map = o.right;
665
+ var tmp$ret$1;
666
+ // Inline function 'kotlin.collections.mapTo' call
667
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
668
+ var indexedObject = tmp1_map;
669
+ var inductionVariable = 0;
670
+ var last = indexedObject.length;
671
+ while (inductionVariable < last) {
672
+ var item = indexedObject[inductionVariable];
673
+ inductionVariable = inductionVariable + 1 | 0;
674
+ var tmp$ret$0;
675
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.handleOuters.<anonymous>' call
676
+ tmp$ret$0 = item.accept($this);
677
+ tmp0_mapTo.g(tmp$ret$0);
678
+ }
679
+ tmp$ret$1 = tmp0_mapTo;
680
+ tmp$ret$2 = tmp$ret$1;
681
+ var operands = plus_0(tmp, tmp$ret$2);
682
+ var tmp$ret$5;
683
+ // Inline function 'kotlin.collections.map' call
684
+ var tmp3_map = o.operators;
685
+ var tmp$ret$4;
686
+ // Inline function 'kotlin.collections.mapTo' call
687
+ var tmp2_mapTo = ArrayList_init_$Create$(tmp3_map.length);
688
+ var indexedObject_0 = tmp3_map;
689
+ var inductionVariable_0 = 0;
690
+ var last_0 = indexedObject_0.length;
691
+ while (inductionVariable_0 < last_0) {
692
+ var item_0 = indexedObject_0[inductionVariable_0];
693
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
694
+ var tmp$ret$3;
695
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.handleOuters.<anonymous>' call
696
+ tmp$ret$3 = item_0.symbol.text;
697
+ tmp2_mapTo.g(tmp$ret$3);
698
+ }
699
+ tmp$ret$4 = tmp2_mapTo;
700
+ tmp$ret$5 = tmp$ret$4;
701
+ var operators = tmp$ret$5;
702
+ var tmp1_subject = o.associativity;
703
+ var tmp_0;
704
+ if (tmp1_subject === Associativity.XFY) {
705
+ tmp_0 = infixRight($this, operands, operators);
706
+ } else if (tmp1_subject === Associativity.XF ? true : tmp1_subject === Associativity.YF) {
707
+ tmp_0 = postfix($this, result, operators);
708
+ } else if (tmp1_subject === Associativity.XFX) {
709
+ tmp_0 = infixNonAssociative($this, operands, operators);
710
+ } else if (tmp1_subject === Associativity.YFX) {
711
+ tmp_0 = infixLeft($this, operands, operators);
712
+ } else if (tmp1_subject === Associativity.FX ? true : tmp1_subject === Associativity.FY) {
713
+ tmp_0 = prefix($this, result, operators);
714
+ } else {
715
+ throw IllegalStateException_init_$Create$();
716
+ }
717
+ result = tmp_0;
718
+ }
719
+ return result;
720
+ }
721
+ function infixRight($this, terms, ops) {
722
+ var i = terms.p() - 1 | 0;
723
+ var j = ops.p() - 1 | 0;
724
+ var tmp0 = j;
725
+ j = tmp0 - 1 | 0;
726
+ var result = $this.f34_1.structOf(ops.o(tmp0), [terms.o(i - 1 | 0), terms.o(i)]);
727
+ i = i - 2 | 0;
728
+ while (i >= 0) {
729
+ var tmp1 = j;
730
+ j = tmp1 - 1 | 0;
731
+ result = $this.f34_1.structOf(ops.o(tmp1), [terms.o(i), result]);
732
+ var tmp2 = i;
733
+ i = tmp2 - 1 | 0;
734
+ }
735
+ return result;
736
+ }
737
+ function infixLeft($this, terms, ops) {
738
+ var i = 0;
739
+ var j = 0;
740
+ var tmp0 = j;
741
+ j = tmp0 + 1 | 0;
742
+ var tmp = ops.o(tmp0);
743
+ var tmp1 = i;
744
+ i = tmp1 + 1 | 0;
745
+ var tmp_0 = terms.o(tmp1);
746
+ var tmp2 = i;
747
+ i = tmp2 + 1 | 0;
748
+ var result = $this.f34_1.structOf(tmp, [tmp_0, terms.o(tmp2)]);
749
+ while (i < terms.p()) {
750
+ var tmp3 = j;
751
+ j = tmp3 + 1 | 0;
752
+ result = $this.f34_1.structOf(ops.o(tmp3), [result, terms.o(i)]);
753
+ var tmp4 = i;
754
+ i = tmp4 + 1 | 0;
755
+ }
756
+ return result;
757
+ }
758
+ function listOfOperands($this, ctx) {
759
+ var tmp$ret$2;
760
+ // Inline function 'kotlin.collections.map' call
761
+ var tmp1_map = plus_0(listOf(ctx.left), toList(ctx.right));
762
+ var tmp$ret$1;
763
+ // Inline function 'kotlin.collections.mapTo' call
764
+ var tmp0_mapTo = ArrayList_init_$Create$(collectionSizeOrDefault(tmp1_map, 10));
765
+ var tmp0_iterator = tmp1_map.j();
766
+ while (tmp0_iterator.m()) {
767
+ var item = tmp0_iterator.n();
768
+ var tmp$ret$0;
769
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.listOfOperands.<anonymous>' call
770
+ tmp$ret$0 = ensureNotNull(item).accept($this);
771
+ tmp0_mapTo.g(tmp$ret$0);
772
+ }
773
+ tmp$ret$1 = tmp0_mapTo;
774
+ tmp$ret$2 = tmp$ret$1;
775
+ return tmp$ret$2;
776
+ }
777
+ function listOfOperators($this, ctx) {
778
+ var tmp$ret$2;
779
+ // Inline function 'kotlin.collections.map' call
780
+ var tmp1_map = ctx.operators;
781
+ var tmp$ret$1;
782
+ // Inline function 'kotlin.collections.mapTo' call
783
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
784
+ var indexedObject = tmp1_map;
785
+ var inductionVariable = 0;
786
+ var last = indexedObject.length;
787
+ while (inductionVariable < last) {
788
+ var item = indexedObject[inductionVariable];
789
+ inductionVariable = inductionVariable + 1 | 0;
790
+ var tmp$ret$0;
791
+ // Inline function 'it.unibo.tuprolog.core.parsing.PrologVisitor.listOfOperators.<anonymous>' call
792
+ tmp$ret$0 = item.symbol.text;
793
+ tmp0_mapTo.g(tmp$ret$0);
794
+ }
795
+ tmp$ret$1 = tmp0_mapTo;
796
+ tmp$ret$2 = tmp$ret$1;
797
+ return tmp$ret$2;
798
+ }
799
+ function visitInfixRightAssociativeExpression($this, ctx) {
800
+ return infixRight($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
801
+ }
802
+ function visitInfixLeftAssociativeExpression($this, ctx) {
803
+ return infixLeft($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
804
+ }
805
+ function flatten($this, outers) {
806
+ var tmp$ret$0;
807
+ // Inline function 'kotlin.sequences.asSequence' call
808
+ tmp$ret$0 = outers;
809
+ var tmp = tmp$ret$0;
810
+ return flatMap(tmp, PrologVisitor$flatten$lambda($this));
811
+ }
812
+ function flatten_0($this, outers) {
813
+ return toList_0(flatten($this, asSequence(outers)));
814
+ }
815
+ function PrologVisitor$visitExpression$ref($boundThis) {
816
+ var l = function (p0) {
817
+ return $boundThis.g34(p0);
818
+ };
819
+ l.callableName = 'visitExpression';
820
+ return l;
821
+ }
822
+ function PrologVisitor$flatten$lambda(this$0) {
823
+ return function (it) {
824
+ return plus_1(sequenceOf([it]), flatten(this$0, asSequence_0(it.outers)));
825
+ };
826
+ }
827
+ function PrologVisitor(scope) {
828
+ scope = scope === VOID ? Companion_getInstance_2().empty() : scope;
829
+ PrologParserVisitor.call(this);
830
+ this.f34_1 = scope;
831
+ }
832
+ protoOf(PrologVisitor).h34 = function (ctx) {
833
+ return this.i34(ctx.term());
834
+ };
835
+ protoOf(PrologVisitor).visitSingletonTerm = function (ctx) {
836
+ return this.h34(ctx);
837
+ };
838
+ protoOf(PrologVisitor).j34 = function (ctx) {
839
+ return this.g34(ctx.expression());
840
+ };
841
+ protoOf(PrologVisitor).visitSingletonExpression = function (ctx) {
842
+ return this.j34(ctx);
843
+ };
844
+ protoOf(PrologVisitor).k34 = function (ctx) {
845
+ return termToClause(ctx.expression().accept(this), null, ensureNotNull(ctx.start).line, ensureNotNull(ctx.start).column);
846
+ };
847
+ protoOf(PrologVisitor).visitClause = function (ctx) {
848
+ return this.k34(ctx);
849
+ };
850
+ protoOf(PrologVisitor).g34 = function (ctx) {
851
+ var tmp;
852
+ if (ctx.isTerm) {
853
+ tmp = this.i34(ensureNotNull(ctx.left));
854
+ } else if (contains(Associativity.INFIX, ctx.associativity)) {
855
+ tmp = visitInfixExpression(this, ctx);
856
+ } else if (contains(Associativity.POSTFIX, ctx.associativity)) {
857
+ tmp = visitPostfixExpression(this, ctx);
858
+ } else if (contains(Associativity.PREFIX, ctx.associativity)) {
859
+ tmp = visitPrefixExpression(this, ctx);
860
+ } else {
861
+ throw IllegalArgumentException_init_$Create$('Associativity unknown: ' + ctx.associativity + ' INFIX=' + Associativity.INFIX + ' PREFIX=' + Associativity.PREFIX + ' POSTFIX=' + Associativity.POSTFIX);
862
+ }
863
+ return handleOuters(this, tmp, flatten_0(this, asList(ctx.outers)));
864
+ };
865
+ protoOf(PrologVisitor).visitExpression = function (ctx) {
866
+ return this.g34(ctx);
867
+ };
868
+ protoOf(PrologVisitor).i34 = function (ctx) {
869
+ var tmp;
870
+ if (ctx.isExpr) {
871
+ tmp = this.g34(ctx.expression());
872
+ } else {
873
+ var tmp_0 = ctx.children[0].accept(this);
874
+ tmp = (!(tmp_0 == null) ? isInterface(tmp_0, Term) : false) ? tmp_0 : THROW_CCE();
875
+ }
876
+ return tmp;
877
+ };
878
+ protoOf(PrologVisitor).visitTerm = function (ctx) {
879
+ return this.i34(ctx);
880
+ };
881
+ protoOf(PrologVisitor).l34 = function (ctx) {
882
+ var value = parseInteger(this, ctx);
883
+ return Companion_getInstance_3().ofBigInteger(value);
884
+ };
885
+ protoOf(PrologVisitor).visitInteger = function (ctx) {
886
+ return this.l34(ctx);
887
+ };
888
+ protoOf(PrologVisitor).m34 = function (ctx) {
889
+ var tmp = ctx.children[0].accept(this);
890
+ return (!(tmp == null) ? isInterface(tmp, Term) : false) ? tmp : THROW_CCE();
891
+ };
892
+ protoOf(PrologVisitor).visitNumber = function (ctx) {
893
+ return this.m34(ctx);
894
+ };
895
+ protoOf(PrologVisitor).n34 = function (ctx) {
896
+ var raw = ctx.value.text;
897
+ if (!(ctx.sign == null)) {
898
+ var tmp0_safe_receiver = ctx.sign;
899
+ raw = plus(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text, raw);
900
+ }
901
+ var tmp;
902
+ try {
903
+ tmp = Companion_getInstance_4().parse(raw);
904
+ } catch ($p) {
905
+ var tmp_0;
906
+ if ($p instanceof NumberFormatException) {
907
+ var notAFloating = $p;
908
+ throw parseException(ctx.value, 'Invalid real number format: ' + ctx.value.text);
909
+ } else {
910
+ throw $p;
911
+ }
912
+ tmp = tmp_0;
913
+ }
914
+ return tmp;
915
+ };
916
+ protoOf(PrologVisitor).visitReal = function (ctx) {
917
+ return this.n34(ctx);
918
+ };
919
+ protoOf(PrologVisitor).o34 = function (ctx) {
920
+ var tmp;
921
+ if (ctx.isAnonymous) {
922
+ tmp = this.f34_1.anonymous();
923
+ } else {
924
+ tmp = this.f34_1.varOf(ctx.value.text);
925
+ }
926
+ return tmp;
927
+ };
928
+ protoOf(PrologVisitor).visitVariable = function (ctx) {
929
+ return this.o34(ctx);
930
+ };
931
+ protoOf(PrologVisitor).p34 = function (ctx) {
932
+ if (ctx.isList) {
933
+ return this.f34_1.listOf([]);
934
+ } else if (ctx.isBlock) {
935
+ return this.f34_1.setOf([]);
936
+ }
937
+ var tmp;
938
+ if (ctx.arity === 0) {
939
+ tmp = this.f34_1.atomOf(ctx.functor.text);
940
+ } else {
941
+ var tmp_0 = ctx.functor.text;
942
+ var tmp_1 = asSequence_0(ctx.args);
943
+ tmp = this.f34_1.structOfSequence(tmp_0, map(tmp_1, PrologVisitor$visitExpression$ref(this)));
944
+ }
945
+ return tmp;
946
+ };
947
+ protoOf(PrologVisitor).visitStructure = function (ctx) {
948
+ return this.p34(ctx);
949
+ };
950
+ protoOf(PrologVisitor).q34 = function (ctx) {
951
+ var tmp$ret$1;
952
+ // Inline function 'kotlin.collections.map' call
953
+ var tmp1_map = ctx.items;
954
+ var tmp$ret$0;
955
+ // Inline function 'kotlin.collections.mapTo' call
956
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
957
+ var indexedObject = tmp1_map;
958
+ var inductionVariable = 0;
959
+ var last = indexedObject.length;
960
+ while (inductionVariable < last) {
961
+ var item = indexedObject[inductionVariable];
962
+ inductionVariable = inductionVariable + 1 | 0;
963
+ tmp0_mapTo.g(this.g34(item));
964
+ }
965
+ tmp$ret$0 = tmp0_mapTo;
966
+ tmp$ret$1 = tmp$ret$0;
967
+ var terms = tmp$ret$1;
968
+ var tmp;
969
+ if (ctx.hasTail) {
970
+ var tmp0_safe_receiver = ctx.tail;
971
+ tmp = this.f34_1.hy(terms, tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept(this));
972
+ } else {
973
+ tmp = this.f34_1.listOfIterable(terms);
974
+ }
975
+ return tmp;
976
+ };
977
+ protoOf(PrologVisitor).visitList = function (ctx) {
978
+ return this.q34(ctx);
979
+ };
980
+ protoOf(PrologVisitor).r34 = function (ctx) {
981
+ var tmp;
982
+ if (ctx.length === 1) {
983
+ tmp = this.f34_1.setOf([ctx.items[0].accept(this)]);
984
+ } else {
985
+ var tmp$ret$1;
986
+ // Inline function 'kotlin.collections.map' call
987
+ var tmp1_map = ctx.items;
988
+ var tmp$ret$0;
989
+ // Inline function 'kotlin.collections.mapTo' call
990
+ var tmp0_mapTo = ArrayList_init_$Create$(tmp1_map.length);
991
+ var indexedObject = tmp1_map;
992
+ var inductionVariable = 0;
993
+ var last = indexedObject.length;
994
+ while (inductionVariable < last) {
995
+ var item = indexedObject[inductionVariable];
996
+ inductionVariable = inductionVariable + 1 | 0;
997
+ tmp0_mapTo.g(this.g34(item));
998
+ }
999
+ tmp$ret$0 = tmp0_mapTo;
1000
+ tmp$ret$1 = tmp$ret$0;
1001
+ tmp = this.f34_1.setOfIterable(tmp$ret$1);
1002
+ }
1003
+ return tmp;
1004
+ };
1005
+ protoOf(PrologVisitor).visitBlock = function (ctx) {
1006
+ return this.r34(ctx);
1007
+ };
1008
+ //region block: exports
1009
+ _.$_$ = _.$_$ || {};
1010
+ _.$_$.a = PrologParserFactory_getInstance;
1011
+ _.$_$.b = PrologVisitor;
1012
+ _.$_$.c = termToClause;
11
1013
  //endregion
12
1014
  return _;
13
1015
  }));