@tuprolog/arg2p 0.14.2 → 0.16.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,125 +1,85 @@
1
1
  (function (factory) {
2
2
  if (typeof define === 'function' && define.amd)
3
- define(['exports', '@tuprolog/parser-utils', 'antlr4', 'antlr4/src/antlr4/error', 'antlr4/src/antlr4/atn', './kotlin-kotlin-stdlib.js', './2p-core.js', './2p-parser-js.js', './kt-math.js'], factory);
3
+ define(['exports', './kotlin-kotlin-stdlib.js', './2p-core.js', './2p-parser-impl.js'], factory);
4
4
  else if (typeof exports === 'object')
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'), require('./2p-core.js'), require('./2p-parser-js.js'), require('./kt-math.js'));
5
+ factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./2p-core.js'), require('./2p-parser-impl.js'));
6
6
  else {
7
- if (typeof globalThis['@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 globalThis['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 globalThis['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
7
  if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
20
8
  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
9
  }
22
10
  if (typeof globalThis['2p-core'] === 'undefined') {
23
11
  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
12
  }
25
- if (typeof globalThis['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'.");
13
+ if (typeof globalThis['2p-parser-impl'] === 'undefined') {
14
+ throw new Error("Error loading module '2p-parser-core'. Its dependency '2p-parser-impl' was not found. Please, check whether '2p-parser-impl' is loaded prior to '2p-parser-core'.");
27
15
  }
28
- if (typeof globalThis['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
- globalThis['2p-parser-core'] = factory(typeof globalThis['2p-parser-core'] === 'undefined' ? {} : globalThis['2p-parser-core'], globalThis['@tuprolog/parser-utils'], antlr4, globalThis['antlr4/src/antlr4/error'], globalThis['antlr4/src/antlr4/atn'], globalThis['kotlin-kotlin-stdlib'], globalThis['2p-core'], globalThis['2p-parser-js'], globalThis['kt-math']);
16
+ globalThis['2p-parser-core'] = factory(typeof globalThis['2p-parser-core'] === 'undefined' ? {} : globalThis['2p-parser-core'], globalThis['kotlin-kotlin-stdlib'], globalThis['2p-core'], globalThis['2p-parser-impl']);
32
17
  }
33
- }(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) {
18
+ }(function (_, kotlin_kotlin, kotlin_it_unibo_tuprolog_core, kotlin_it_unibo_tuprolog_parser_impl) {
34
19
  'use strict';
35
20
  //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;
21
+ var imul = Math.imul;
47
22
  var VOID = kotlin_kotlin.$_$.b;
48
- var captureStack = kotlin_kotlin.$_$.m5;
49
- var protoOf = kotlin_kotlin.$_$.n6;
50
- var initMetadataForClass = kotlin_kotlin.$_$.a6;
51
- var TuPrologException = kotlin_it_unibo_tuprolog_core.$_$.c1;
52
- var TuPrologException_init_$Init$ = kotlin_it_unibo_tuprolog_core.$_$.e;
53
- var ensureNotNull = kotlin_kotlin.$_$.ua;
54
- var replace = kotlin_kotlin.$_$.o9;
55
- var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.d1;
56
- var Char = kotlin_kotlin.$_$.ea;
57
- var toString = kotlin_kotlin.$_$.h1;
58
- var Struct = kotlin_it_unibo_tuprolog_core.$_$.s1;
59
- var isInterface = kotlin_kotlin.$_$.h6;
60
- var Numeric = kotlin_it_unibo_tuprolog_core.$_$.o1;
61
- var Atom = kotlin_it_unibo_tuprolog_core.$_$.f1;
62
- var Companion_getInstance = kotlin_it_unibo_tuprolog_core.$_$.i;
63
- var Companion_instance = kotlin_it_unibo_tuprolog_core.$_$.t;
64
- var OperatorSet_init_$Create$ = kotlin_it_unibo_tuprolog_core.$_$.f;
65
- var initMetadataForCompanion = kotlin_kotlin.$_$.b6;
66
- var getKClass = kotlin_kotlin.$_$.f7;
67
- var Constant = kotlin_it_unibo_tuprolog_core.$_$.h1;
68
- var Var = kotlin_it_unibo_tuprolog_core.$_$.t2;
69
- var Integer = kotlin_it_unibo_tuprolog_core.$_$.m1;
70
- var Real = kotlin_it_unibo_tuprolog_core.$_$.p1;
71
- var Clause = kotlin_it_unibo_tuprolog_core.$_$.g1;
72
- var Rule = kotlin_it_unibo_tuprolog_core.$_$.q1;
73
- var Fact = kotlin_it_unibo_tuprolog_core.$_$.k1;
74
- var Directive = kotlin_it_unibo_tuprolog_core.$_$.j1;
75
- var initMetadataForInterface = kotlin_kotlin.$_$.c6;
76
- var Companion_instance_0 = kotlin_it_unibo_tuprolog_core.$_$.m;
77
- var toString_0 = kotlin_kotlin.$_$.q6;
78
- var Unit_instance = kotlin_kotlin.$_$.l1;
79
- var THROW_CCE = kotlin_kotlin.$_$.qa;
80
- var contains = kotlin_kotlin.$_$.e2;
81
- var Companion_getInstance_0 = kotlin_it_unibo_tuprolog_core.$_$.j;
82
- var map = kotlin_kotlin.$_$.g8;
83
- var Operator = kotlin_it_unibo_tuprolog_core.$_$.e1;
84
- var List = kotlin_it_unibo_tuprolog_core.$_$.n1;
85
- var coerceAtLeast = kotlin_kotlin.$_$.b7;
86
- var isRecognitionException = kotlin_it_unibo_tuprolog_parser_js.$_$.b;
87
- var isParseCancellationException = kotlin_it_unibo_tuprolog_parser_js.$_$.a;
88
- var generateSequence = kotlin_kotlin.$_$.a8;
89
- var takeWhile = kotlin_kotlin.$_$.r8;
90
- var to = kotlin_kotlin.$_$.cb;
91
- var initMetadataForObject = kotlin_kotlin.$_$.e6;
92
- var substring = kotlin_kotlin.$_$.u9;
93
- var Companion_getInstance_1 = kotlin_io_github_gciatto_kt_math.$_$.e;
94
- var charCodeAt = kotlin_kotlin.$_$.p5;
95
- var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.g1;
96
- var contains_0 = kotlin_kotlin.$_$.d9;
97
- var plus = kotlin_kotlin.$_$.ya;
98
- var ArrayList_init_$Create$ = kotlin_kotlin.$_$.c;
99
- var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.t;
100
- var listOf = kotlin_kotlin.$_$.d3;
101
- var asList = kotlin_kotlin.$_$.w1;
102
- var plus_0 = kotlin_kotlin.$_$.x3;
103
- var collectionSizeOrDefault = kotlin_kotlin.$_$.c2;
104
- var toList = kotlin_kotlin.$_$.g4;
105
- var flatMap = kotlin_kotlin.$_$.x7;
106
- var asSequence = kotlin_kotlin.$_$.a2;
107
- var toList_0 = kotlin_kotlin.$_$.v8;
108
- var sequenceOf = kotlin_kotlin.$_$.n8;
109
- var asSequence_0 = kotlin_kotlin.$_$.b2;
110
- var plus_1 = kotlin_kotlin.$_$.k8;
111
- var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.q;
112
- var Term = kotlin_it_unibo_tuprolog_core.$_$.r2;
113
- var Companion_getInstance_2 = kotlin_it_unibo_tuprolog_core.$_$.o;
114
- var Companion_getInstance_3 = kotlin_it_unibo_tuprolog_core.$_$.r;
115
- var NumberFormatException = kotlin_kotlin.$_$.na;
23
+ var captureStack = kotlin_kotlin.$_$.c6;
24
+ var protoOf = kotlin_kotlin.$_$.f7;
25
+ var initMetadataForClass = kotlin_kotlin.$_$.s6;
26
+ var TuPrologException = kotlin_it_unibo_tuprolog_core.$_$.d1;
27
+ var TuPrologException_init_$Init$ = kotlin_it_unibo_tuprolog_core.$_$.a1;
28
+ var replace = kotlin_kotlin.$_$.ka;
29
+ var getKClassFromExpression = kotlin_kotlin.$_$.x7;
30
+ var getKClass = kotlin_kotlin.$_$.y7;
31
+ var toString = kotlin_kotlin.$_$.i7;
32
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.h1;
33
+ var collectionSizeOrDefault = kotlin_kotlin.$_$.j2;
34
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.p;
35
+ var Unit_instance = kotlin_kotlin.$_$.o;
36
+ var ensureNotNull = kotlin_kotlin.$_$.sb;
37
+ var visit = kotlin_it_unibo_tuprolog_parser_impl.$_$.p;
38
+ var visitExpression = kotlin_it_unibo_tuprolog_parser_impl.$_$.m;
39
+ var visitClause = kotlin_it_unibo_tuprolog_parser_impl.$_$.l;
40
+ var visitTerm = kotlin_it_unibo_tuprolog_parser_impl.$_$.o;
41
+ var visitParenthesizedExpression = kotlin_it_unibo_tuprolog_parser_impl.$_$.n;
42
+ var SyntaxNodeVisitor = kotlin_it_unibo_tuprolog_parser_impl.$_$.q;
43
+ var Companion_getInstance = kotlin_it_unibo_tuprolog_core.$_$.b;
44
+ var Companion_instance = kotlin_it_unibo_tuprolog_core.$_$.m;
45
+ var OperatorSet_init_$Create$ = kotlin_it_unibo_tuprolog_core.$_$.b1;
46
+ var initMetadataForCompanion = kotlin_kotlin.$_$.t6;
47
+ var Struct = kotlin_it_unibo_tuprolog_core.$_$.t1;
48
+ var isInterface = kotlin_kotlin.$_$.z6;
49
+ var Constant = kotlin_it_unibo_tuprolog_core.$_$.i1;
50
+ var Var = kotlin_it_unibo_tuprolog_core.$_$.u2;
51
+ var Atom = kotlin_it_unibo_tuprolog_core.$_$.g1;
52
+ var Numeric = kotlin_it_unibo_tuprolog_core.$_$.p1;
53
+ var Integer = kotlin_it_unibo_tuprolog_core.$_$.n1;
54
+ var Real = kotlin_it_unibo_tuprolog_core.$_$.q1;
55
+ var Clause = kotlin_it_unibo_tuprolog_core.$_$.h1;
56
+ var Rule = kotlin_it_unibo_tuprolog_core.$_$.r1;
57
+ var Fact = kotlin_it_unibo_tuprolog_core.$_$.l1;
58
+ var Directive = kotlin_it_unibo_tuprolog_core.$_$.k1;
59
+ var initMetadataForInterface = kotlin_kotlin.$_$.u6;
60
+ var Companion_instance_0 = kotlin_it_unibo_tuprolog_core.$_$.f;
61
+ var PrologSyntaxException = kotlin_it_unibo_tuprolog_parser_impl.$_$.j;
62
+ var LexerOptions = kotlin_it_unibo_tuprolog_parser_impl.$_$.r;
63
+ var ParserOptions = kotlin_it_unibo_tuprolog_parser_impl.$_$.s;
64
+ var buildParserFor = kotlin_it_unibo_tuprolog_parser_impl.$_$.t;
65
+ var OperatorTables_instance = kotlin_it_unibo_tuprolog_parser_impl.$_$.a;
66
+ var OperatorDefinition = kotlin_it_unibo_tuprolog_parser_impl.$_$.k;
67
+ var Associativity_FX_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.b;
68
+ var Associativity_FY_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.c;
69
+ var Associativity_XF_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.f;
70
+ var Associativity_YF_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.h;
71
+ var Associativity_XFX_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.d;
72
+ var Associativity_YFX_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.g;
73
+ var Associativity_XFY_getInstance = kotlin_it_unibo_tuprolog_parser_impl.$_$.e;
74
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.vb;
116
75
  //endregion
117
76
  //region block: pre-declaration
118
77
  initMetadataForClass(ParseException, 'ParseException', VOID, TuPrologException);
119
78
  initMetadataForClass(InvalidTermTypeException, 'InvalidTermTypeException', VOID, ParseException);
79
+ initMetadataForClass(PrologTermParserVisitor, 'PrologTermParserVisitor', VOID, VOID, [SyntaxNodeVisitor]);
120
80
  initMetadataForCompanion(Companion);
121
81
  function parseTerm(input) {
122
- return this.parseTermWithOperators(input, this.q38());
82
+ return this.parseTermWithOperators(input, this.n3o());
123
83
  }
124
84
  function parseStructWithOperators(input, operators) {
125
85
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -135,7 +95,7 @@
135
95
  return tmp;
136
96
  }
137
97
  function parseStruct(input) {
138
- return this.parseStructWithOperators(input, this.q38());
98
+ return this.parseStructWithOperators(input, this.n3o());
139
99
  }
140
100
  function parseConstantWithOperators(input, operators) {
141
101
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -151,7 +111,7 @@
151
111
  return tmp;
152
112
  }
153
113
  function parseConstant(input) {
154
- return this.parseConstantWithOperators(input, this.q38());
114
+ return this.parseConstantWithOperators(input, this.n3o());
155
115
  }
156
116
  function parseVarWithOperators(input, operators) {
157
117
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -167,7 +127,7 @@
167
127
  return tmp;
168
128
  }
169
129
  function parseVar(input) {
170
- return this.parseVarWithOperators(input, this.q38());
130
+ return this.parseVarWithOperators(input, this.n3o());
171
131
  }
172
132
  function parseAtomWithOperators(input, operators) {
173
133
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -183,7 +143,7 @@
183
143
  return tmp;
184
144
  }
185
145
  function parseAtom(input) {
186
- return this.parseAtomWithOperators(input, this.q38());
146
+ return this.parseAtomWithOperators(input, this.n3o());
187
147
  }
188
148
  function parseNumericWithOperators(input, operators) {
189
149
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -199,7 +159,7 @@
199
159
  return tmp;
200
160
  }
201
161
  function parseNumeric(input) {
202
- return this.parseNumericWithOperators(input, this.q38());
162
+ return this.parseNumericWithOperators(input, this.n3o());
203
163
  }
204
164
  function parseIntegerWithOperators(input, operators) {
205
165
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -215,7 +175,7 @@
215
175
  return tmp;
216
176
  }
217
177
  function parseInteger(input) {
218
- return this.parseIntegerWithOperators(input, this.q38());
178
+ return this.parseIntegerWithOperators(input, this.n3o());
219
179
  }
220
180
  function parseRealWithOperators(input, operators) {
221
181
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -231,7 +191,7 @@
231
191
  return tmp;
232
192
  }
233
193
  function parseReal(input) {
234
- return this.parseRealWithOperators(input, this.q38());
194
+ return this.parseRealWithOperators(input, this.n3o());
235
195
  }
236
196
  function parseClauseWithOperators(input, operators) {
237
197
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -247,7 +207,7 @@
247
207
  return tmp;
248
208
  }
249
209
  function parseClause(input) {
250
- return this.parseClauseWithOperators(input, this.q38());
210
+ return this.parseClauseWithOperators(input, this.n3o());
251
211
  }
252
212
  function parseRuleWithOperators(input, operators) {
253
213
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -263,7 +223,7 @@
263
223
  return tmp;
264
224
  }
265
225
  function parseRule(input) {
266
- return this.parseRuleWithOperators(input, this.q38());
226
+ return this.parseRuleWithOperators(input, this.n3o());
267
227
  }
268
228
  function parseFactWithOperators(input, operators) {
269
229
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -279,7 +239,7 @@
279
239
  return tmp;
280
240
  }
281
241
  function parseFact(input) {
282
- return this.parseFactWithOperators(input, this.q38());
242
+ return this.parseFactWithOperators(input, this.n3o());
283
243
  }
284
244
  function parseDirectiveWithOperators(input, operators) {
285
245
  // Inline function 'it.unibo.tuprolog.core.parsing.Companion.parseAs' call
@@ -295,14 +255,9 @@
295
255
  return tmp;
296
256
  }
297
257
  function parseDirective(input) {
298
- return this.parseDirectiveWithOperators(input, this.q38());
258
+ return this.parseDirectiveWithOperators(input, this.n3o());
299
259
  }
300
260
  initMetadataForInterface(TermParser, 'TermParser');
301
- initMetadataForCompanion(Companion_0);
302
- initMetadataForClass(DynamicOpListener, 'DynamicOpListener', VOID, PrologParserListener);
303
- initMetadataForClass(PrologParserFactory$newErrorListener$1);
304
- initMetadataForObject(PrologParserFactory, 'PrologParserFactory');
305
- initMetadataForClass(PrologVisitor, 'PrologVisitor', PrologVisitor, PrologParserVisitor);
306
261
  initMetadataForClass(TermParserImpl, 'TermParserImpl', VOID, VOID, [TermParser]);
307
262
  //endregion
308
263
  function InvalidTermTypeException(input, term, type, offendingSymbol, line, column, message, throwable) {
@@ -316,12 +271,12 @@
316
271
  offendingSymbol = tmp;
317
272
  line = line === VOID ? 1 : line;
318
273
  column = column === VOID ? 1 : column;
319
- message = message === VOID ? 'Expected ' + type.b9() + ', got: ' + offendingSymbol : message;
274
+ message = message === VOID ? 'Expected ' + type.e9() + ', got: ' + offendingSymbol : message;
320
275
  throwable = throwable === VOID ? null : throwable;
321
276
  ParseException.call(this, input, offendingSymbol, line, column, message, throwable);
322
277
  captureStack(this, InvalidTermTypeException);
323
- this.z37_1 = term;
324
- this.a38_1 = type;
278
+ this.w3n_1 = term;
279
+ this.x3n_1 = type;
325
280
  }
326
281
  function ParseException(input, offendingSymbol, line, column, message, throwable) {
327
282
  TuPrologException_init_$Init$(message, throwable, this);
@@ -332,113 +287,181 @@
332
287
  this.column = column;
333
288
  this.clauseIndex = -1;
334
289
  }
335
- protoOf(ParseException).b38 = function (_set____db54di) {
290
+ protoOf(ParseException).y3n = function (_set____db54di) {
336
291
  this.input = _set____db54di;
337
292
  };
338
- protoOf(ParseException).c38 = function () {
293
+ protoOf(ParseException).a3i = function () {
339
294
  return this.input;
340
295
  };
341
- protoOf(ParseException).d38 = function (_set____db54di) {
296
+ protoOf(ParseException).z3n = function (_set____db54di) {
342
297
  this.offendingSymbol = _set____db54di;
343
298
  };
344
- protoOf(ParseException).e38 = function () {
299
+ protoOf(ParseException).a3o = function () {
345
300
  return this.offendingSymbol;
346
301
  };
347
- protoOf(ParseException).f38 = function (_set____db54di) {
302
+ protoOf(ParseException).b3o = function (_set____db54di) {
348
303
  this.line = _set____db54di;
349
304
  };
350
- protoOf(ParseException).g38 = function () {
305
+ protoOf(ParseException).c3o = function () {
351
306
  return this.line;
352
307
  };
353
- protoOf(ParseException).h38 = function (_set____db54di) {
308
+ protoOf(ParseException).d3o = function (_set____db54di) {
354
309
  this.column = _set____db54di;
355
310
  };
356
- protoOf(ParseException).i38 = function () {
311
+ protoOf(ParseException).e3o = function () {
357
312
  return this.column;
358
313
  };
359
- protoOf(ParseException).j38 = function (_set____db54di) {
314
+ protoOf(ParseException).f3o = function (_set____db54di) {
360
315
  this.clauseIndex = _set____db54di;
361
316
  };
362
- protoOf(ParseException).k38 = function () {
317
+ protoOf(ParseException).g3o = function () {
363
318
  return this.clauseIndex;
364
319
  };
365
320
  protoOf(ParseException).toString = function () {
366
- 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));
367
- };
368
- function get_isOpDirective(_this__u8e3s4) {
321
+ var tmp0_safe_receiver = this.message;
322
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : replace(tmp0_safe_receiver, '\\n', '\\\\n');
369
323
  var tmp;
370
- var tmp_0;
371
- var tmp_1;
372
- var tmp_2;
373
- var tmp_3;
374
- if (isInterface(_this__u8e3s4, Struct)) {
375
- tmp_3 = _this__u8e3s4.zu() === 3;
324
+ if (tmp1_safe_receiver == null) {
325
+ tmp = null;
376
326
  } else {
377
- tmp_3 = false;
327
+ // Inline function 'kotlin.let' call
328
+ tmp = '"' + tmp1_safe_receiver + '"';
378
329
  }
379
- if (tmp_3) {
380
- tmp_2 = _this__u8e3s4.fv() === 'op';
381
- } else {
382
- tmp_2 = false;
330
+ var tmp2_elvis_lhs = tmp;
331
+ var message = tmp2_elvis_lhs == null ? 'null' : tmp2_elvis_lhs;
332
+ var result = 'ParseException{message=' + message + ', line=' + this.line + ', column=' + this.column;
333
+ if (this.clauseIndex >= 0) {
334
+ result = result + (', clauseIndex' + this.clauseIndex);
383
335
  }
384
- if (tmp_2) {
385
- tmp_1 = _this__u8e3s4.jw();
386
- } else {
387
- tmp_1 = false;
388
- }
389
- if (tmp_1) {
390
- var tmp_4 = _this__u8e3s4.get(0);
391
- tmp_0 = isInterface(tmp_4, Numeric);
392
- } else {
393
- tmp_0 = false;
336
+ if (!(this.offendingSymbol == null)) {
337
+ result = result + (', offendingSymbol="' + this.offendingSymbol + '"');
394
338
  }
395
- if (tmp_0) {
396
- var tmp_5 = _this__u8e3s4.get(1);
397
- tmp = isInterface(tmp_5, Atom);
339
+ return result + '}';
340
+ };
341
+ function PrologTermParserVisitor(scope) {
342
+ this.h3o_1 = scope;
343
+ }
344
+ protoOf(PrologTermParserVisitor).p3n = function (node) {
345
+ // Inline function 'kotlin.error' call
346
+ var message = '[BUG] ' + getKClassFromExpression(node).e9() + ' should not be visited by ' + getKClass(PrologTermParserVisitor).e9();
347
+ throw IllegalStateException_init_$Create$(toString(message));
348
+ };
349
+ protoOf(PrologTermParserVisitor).i3n = function (node) {
350
+ var tmp = node.p3l().k3n_1.x3b_1;
351
+ // Inline function 'kotlin.collections.map' call
352
+ var this_0 = node.a3k();
353
+ // Inline function 'kotlin.collections.mapTo' call
354
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
355
+ var _iterator__ex2g4s = this_0.n();
356
+ while (_iterator__ex2g4s.q()) {
357
+ var item = _iterator__ex2g4s.r();
358
+ var tmp$ret$2 = item.b3k(this);
359
+ destination.k(tmp$ret$2);
360
+ }
361
+ return this.h3o_1.structOfList(tmp, destination);
362
+ };
363
+ protoOf(PrologTermParserVisitor).h3n = function (node) {
364
+ var signedDigits = node.d3l() < 0 ? '-' + node.f3l() : node.f3l();
365
+ switch (node.c3l().m2_1) {
366
+ case 5:
367
+ return this.h3o_1.parseReal(signedDigits);
368
+ case 4:
369
+ return this.h3o_1.intOf(imul(node.d3l(), ensureNotNull(node.g3l())));
370
+ default:
371
+ return this.h3o_1.parseIntRadix(signedDigits, ensureNotNull(node.e3l()));
372
+ }
373
+ };
374
+ protoOf(PrologTermParserVisitor).r3n = function (node) {
375
+ var tmp;
376
+ if (node.m14()) {
377
+ tmp = this.h3o_1.anonymous();
398
378
  } else {
399
- tmp = false;
379
+ tmp = this.h3o_1.varOf(node.n2());
400
380
  }
401
381
  return tmp;
402
- }
382
+ };
383
+ protoOf(PrologTermParserVisitor).n3n = function (node) {
384
+ var tmp = node.ov();
385
+ // Inline function 'kotlin.collections.map' call
386
+ var this_0 = node.a3k();
387
+ // Inline function 'kotlin.collections.mapTo' call
388
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
389
+ var _iterator__ex2g4s = this_0.n();
390
+ while (_iterator__ex2g4s.q()) {
391
+ var item = _iterator__ex2g4s.r();
392
+ var tmp$ret$2 = item.b3k(this);
393
+ destination.k(tmp$ret$2);
394
+ }
395
+ return this.h3o_1.structOfList(tmp, destination);
396
+ };
397
+ protoOf(PrologTermParserVisitor).g3n = function (node) {
398
+ // Inline function 'kotlin.collections.map' call
399
+ var this_0 = node.bx();
400
+ // Inline function 'kotlin.collections.mapTo' call
401
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
402
+ var _iterator__ex2g4s = this_0.n();
403
+ while (_iterator__ex2g4s.q()) {
404
+ var item = _iterator__ex2g4s.r();
405
+ var tmp$ret$2 = item.b3k(this);
406
+ destination.k(tmp$ret$2);
407
+ }
408
+ var tmp = destination;
409
+ var tmp0_safe_receiver = node.ky();
410
+ var tmp1_elvis_lhs = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.b3k(this);
411
+ return this.h3o_1.f11(tmp, tmp1_elvis_lhs == null ? this.h3o_1.c11() : tmp1_elvis_lhs);
412
+ };
413
+ protoOf(PrologTermParserVisitor).d3n = function (node) {
414
+ // Inline function 'kotlin.collections.map' call
415
+ var this_0 = node.bx();
416
+ // Inline function 'kotlin.collections.mapTo' call
417
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
418
+ var _iterator__ex2g4s = this_0.n();
419
+ while (_iterator__ex2g4s.q()) {
420
+ var item = _iterator__ex2g4s.r();
421
+ var tmp$ret$2 = item.b3k(this);
422
+ destination.k(tmp$ret$2);
423
+ }
424
+ return this.h3o_1.blockOfIterable(destination);
425
+ };
403
426
  function Companion() {
404
427
  }
405
- protoOf(Companion).l38 = function (scope) {
406
- return this.m38(Companion_getInstance().EMPTY, scope);
428
+ protoOf(Companion).i3o = function (scope) {
429
+ return this.j3o(Companion_getInstance().EMPTY, scope);
407
430
  };
408
431
  protoOf(Companion).withNoOperator = function (scope, $super) {
409
432
  scope = scope === VOID ? Companion_instance.empty() : scope;
410
- return $super === VOID ? this.l38(scope) : $super.l38.call(this, scope);
433
+ return $super === VOID ? this.i3o(scope) : $super.i3o.call(this, scope);
411
434
  };
412
- protoOf(Companion).n38 = function (scope) {
413
- return this.m38(Companion_getInstance().STANDARD, scope);
435
+ protoOf(Companion).k3o = function (scope) {
436
+ return this.j3o(Companion_getInstance().STANDARD, scope);
414
437
  };
415
438
  protoOf(Companion).withStandardOperators = function (scope, $super) {
416
439
  scope = scope === VOID ? Companion_instance.empty() : scope;
417
- return $super === VOID ? this.n38(scope) : $super.n38.call(this, scope);
440
+ return $super === VOID ? this.k3o(scope) : $super.k3o.call(this, scope);
418
441
  };
419
- protoOf(Companion).o38 = function (scope) {
420
- return this.m38(Companion_getInstance().DEFAULT, scope);
442
+ protoOf(Companion).l3o = function (scope) {
443
+ return this.j3o(Companion_getInstance().DEFAULT, scope);
421
444
  };
422
445
  protoOf(Companion).withDefaultOperators = function (scope, $super) {
423
446
  scope = scope === VOID ? Companion_instance.empty() : scope;
424
- return $super === VOID ? this.o38(scope) : $super.o38.call(this, scope);
447
+ return $super === VOID ? this.l3o(scope) : $super.l3o.call(this, scope);
425
448
  };
426
- protoOf(Companion).m38 = function (operators, scope) {
427
- return termParserWithOperators(operators, scope);
449
+ protoOf(Companion).j3o = function (operators, scope) {
450
+ return new TermParserImpl(scope, operators);
428
451
  };
429
452
  protoOf(Companion).withOperatorSet = function (operators, scope, $super) {
430
453
  scope = scope === VOID ? Companion_instance.empty() : scope;
431
- return $super === VOID ? this.m38(operators, scope) : $super.m38.call(this, operators, scope);
454
+ return $super === VOID ? this.j3o(operators, scope) : $super.j3o.call(this, operators, scope);
432
455
  };
433
- protoOf(Companion).p38 = function (operators, scope) {
434
- return this.m38(OperatorSet_init_$Create$(operators.slice()), scope);
456
+ protoOf(Companion).m3o = function (operators, scope) {
457
+ return this.j3o(OperatorSet_init_$Create$(operators.slice()), scope);
435
458
  };
436
459
  protoOf(Companion).withOperators = function (operators, scope, $super) {
437
460
  scope = scope === VOID ? Companion_instance.empty() : scope;
438
- return $super === VOID ? this.p38(operators, scope) : $super.p38.call(this, operators, scope);
461
+ return $super === VOID ? this.m3o(operators, scope) : $super.m3o.call(this, operators, scope);
439
462
  };
440
463
  var Companion_instance_1;
441
- function Companion_getInstance_4() {
464
+ function Companion_getInstance_0() {
442
465
  return Companion_instance_1;
443
466
  }
444
467
  function TermParser() {
@@ -474,209 +497,18 @@
474
497
  function parseClause_0(_this__u8e3s4, input) {
475
498
  return get_defaultParser().parseClause(input);
476
499
  }
477
- function toAssociativity(_this__u8e3s4) {
478
- return toString_0(_this__u8e3s4);
479
- }
480
- function DynamicOpListener$Companion$of$lambda($this$DynamicOpListener, it) {
481
- return Unit_instance;
482
- }
483
- function onOperatorDefined($this, operator) {
484
- $this.r38_1.addOperator(operator.e1h_1, toAssociativity(operator.f1h_1), operator.g1h_1);
485
- $this.s38_1($this.r38_1, operator);
486
- }
487
- function Companion_0() {
488
- }
489
- protoOf(Companion_0).t38 = function (parser) {
490
- return new DynamicOpListener(parser, DynamicOpListener$Companion$of$lambda);
491
- };
492
- var Companion_instance_2;
493
- function Companion_getInstance_5() {
494
- return Companion_instance_2;
495
- }
496
- function DynamicOpListener$exitClause$lambda(it) {
497
- return isInterface(it, Atom) ? it : THROW_CCE();
498
- }
499
- function DynamicOpListener(parser, operatorDefinedCallback) {
500
- PrologParserListener.call(this);
501
- this.r38_1 = parser;
502
- this.s38_1 = operatorDefinedCallback;
503
- }
504
- protoOf(DynamicOpListener).u38 = function (ctx) {
505
- var expr = ctx.expression();
506
- if (ctx.exception != null) {
507
- return Unit_instance;
508
- }
509
- var tmp;
510
- var tmp_0;
511
- if (!(expr._op == null)) {
512
- var tmp0_safe_receiver = expr._op;
513
- var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.symbol;
514
- tmp_0 = ':-' === (tmp1_safe_receiver == null ? null : tmp1_safe_receiver.text);
515
- } else {
516
- tmp_0 = false;
517
- }
518
- if (tmp_0) {
519
- tmp = contains(Associativity.PREFIX, expr.associativity);
520
- } else {
521
- tmp = false;
522
- }
523
- if (tmp) {
524
- var tmp_1 = ctx.accept(new PrologVisitor());
525
- var directive = isInterface(tmp_1, Directive) ? tmp_1 : THROW_CCE();
526
- var op = directive.mx();
527
- if (get_isOpDirective(op)) {
528
- var tmp_2 = (isInterface(op, Struct) ? op : THROW_CCE()).get(0);
529
- // Inline function 'kotlin.math.max' call
530
- var b = (isInterface(tmp_2, Numeric) ? tmp_2 : THROW_CCE()).nz().toInt();
531
- // Inline function 'kotlin.math.min' call
532
- var b_0 = Math.max(0, b);
533
- var priority = Math.min(1200, b_0);
534
- var specifier = Companion_getInstance_0().fromTerm(op.get(1));
535
- var operator = op.get(2);
536
- if (isInterface(operator, Atom)) {
537
- onOperatorDefined(this, new Operator(operator.e2(), specifier, priority));
538
- } else {
539
- if (isInterface(operator, List)) {
540
- var tmp0 = operator.vt();
541
- var tmp$ret$3;
542
- $l$block: {
543
- // Inline function 'kotlin.sequences.all' call
544
- var _iterator__ex2g4s = tmp0.p();
545
- while (_iterator__ex2g4s.s()) {
546
- var element = _iterator__ex2g4s.t();
547
- if (!isInterface(element, Atom)) {
548
- tmp$ret$3 = false;
549
- break $l$block;
550
- }
551
- }
552
- tmp$ret$3 = true;
553
- }
554
- if (tmp$ret$3) {
555
- var tmp_3 = operator.vt();
556
- var _iterator__ex2g4s_0 = map(tmp_3, DynamicOpListener$exitClause$lambda).p();
557
- while (_iterator__ex2g4s_0.s()) {
558
- var it = _iterator__ex2g4s_0.t();
559
- onOperatorDefined(this, new Operator(it.e2(), specifier, priority));
560
- }
561
- }
562
- }
563
- }
564
- }
565
- }
566
- };
567
- protoOf(DynamicOpListener).exitClause = function (ctx) {
568
- return this.u38(ctx);
569
- };
570
- function parseException(token, message) {
571
- return new ParseException(null, token.text, token.line, token.column, message, null);
572
- }
573
- function symbolToString($this, obj) {
574
- var tmp;
575
- if (obj instanceof Token) {
576
- tmp = obj.text;
577
- } else {
578
- tmp = toString_0(obj);
579
- }
580
- return tmp;
581
- }
582
- function newErrorListener($this, whileParsing) {
583
- return new PrologParserFactory$newErrorListener$1(whileParsing);
584
- }
585
- function parseExpression($this, parserAndErrorStrategy, source) {
586
- var mark = -1;
587
- var index = -1;
588
- var parser = parserAndErrorStrategy.first;
589
- var tmp;
590
- try {
591
- mark = parser.getTokenStream().mark();
592
- index = coerceAtLeast(parser.getTokenStream().index, 0);
593
- tmp = parser.singletonExpression();
594
- } catch ($p) {
595
- var tmp_0;
596
- var e = $p;
597
- var tmp_1;
598
- if (isParseCancellationException(e) && parser._interp.predictionMode === PredictionMode.SLL) {
599
- parser.getTokenStream().seek(index);
600
- parser._interp.predictionMode = PredictionMode.LL;
601
- parser._errHandler = parserAndErrorStrategy.second;
602
- parser.addErrorListener(newErrorListener($this, source));
603
- tmp_1 = parseExpression($this, parserAndErrorStrategy, source);
604
- } else if (e.clause !== null && isRecognitionException(e.cause)) {
605
- var tmp_2 = e.cause;
606
- throw tmp_2 instanceof RecognitionException ? tmp_2 : THROW_CCE();
607
- } else {
608
- throw e instanceof Error ? e : THROW_CCE();
609
- }
610
- tmp_0 = tmp_1;
611
- tmp = tmp_0;
612
- }
613
- finally {
614
- parser.getTokenStream().release(mark);
615
- }
616
- return tmp;
617
- }
618
- function parseClause_1($this, parserAndErrorStrategy, source) {
619
- var mark = -1;
620
- var index = -1;
621
- var parser = parserAndErrorStrategy.first;
622
- var tmp;
623
- try {
624
- mark = parser.getTokenStream().mark();
625
- index = coerceAtLeast(parser.getTokenStream().index, 0);
626
- tmp = parser.optClause();
627
- } catch ($p) {
628
- var tmp_0;
629
- var e = $p;
630
- var tmp_1;
631
- if (isParseCancellationException(e) && parser._interp.predictionMode === PredictionMode.SLL) {
632
- parser.getTokenStream().seek(index);
633
- parser._interp.predictionMode = PredictionMode.LL;
634
- parser._errHandler = parserAndErrorStrategy.second;
635
- parser.addErrorListener(newErrorListener($this, source));
636
- tmp_1 = parseClause_1($this, parserAndErrorStrategy, source);
637
- } else if (e.clause !== null && isRecognitionException(e.cause)) {
638
- var tmp_2 = e.cause;
639
- throw tmp_2 instanceof RecognitionException ? tmp_2 : THROW_CCE();
640
- } else {
641
- throw e instanceof Error ? e : THROW_CCE();
642
- }
643
- tmp_0 = tmp_1;
644
- tmp = tmp_0;
645
- }
646
- finally {
647
- parser.getTokenStream().release(mark);
648
- }
649
- return tmp;
650
- }
651
- function parseClauses($this, parser, source) {
652
- var tmp = generateSequence(0, PrologParserFactory$parseClauses$lambda);
653
- var tmp_0 = map(tmp, PrologParserFactory$parseClauses$lambda_0(parser, source));
654
- var tmp_1 = takeWhile(tmp_0, PrologParserFactory$parseClauses$lambda_1);
655
- return map(tmp_1, PrologParserFactory$parseClauses$lambda_2);
656
- }
657
- function PrologParserFactory$newErrorListener$1($whileParsing) {
658
- this.v38_1 = $whileParsing;
659
- }
660
- protoOf(PrologParserFactory$newErrorListener$1).syntaxError = function (recognizer, offendingSymbol, line, column, msg, e) {
661
- if (recognizer instanceof PrologParser) {
662
- recognizer.removeParseListeners();
663
- }
664
- throw new ParseException(this.v38_1, symbolToString(this, offendingSymbol), line, column + 1 | 0, msg, e);
665
- };
666
- function PrologParserFactory$parseClauses$lambda(it) {
667
- return it + 1 | 0;
668
- }
669
- function PrologParserFactory$parseClauses$lambda_0($parser, $source) {
670
- return function (it) {
500
+ function TermParserImpl$parseTerm$lambda($operators, this$0, $input) {
501
+ return function (parser, lexedSource) {
671
502
  var tmp;
672
503
  try {
673
- tmp = parseClause_1(PrologParserFactory_instance, $parser, $source);
504
+ var syntaxTree = parser.q3i(lexedSource, toOperatorTable($operators));
505
+ var visitor = new PrologTermParserVisitor(this$0.o3o_1);
506
+ tmp = syntaxTree.t3n_1.b3k(visitor);
674
507
  } catch ($p) {
675
508
  var tmp_0;
676
- if ($p instanceof ParseException) {
509
+ if ($p instanceof PrologSyntaxException) {
677
510
  var e = $p;
678
- e.clauseIndex = it;
679
- throw e;
511
+ throw toParseException(e, $input);
680
512
  } else {
681
513
  throw $p;
682
514
  }
@@ -684,519 +516,78 @@
684
516
  return tmp;
685
517
  };
686
518
  }
687
- function PrologParserFactory$parseClauses$lambda_1(it) {
688
- return !it.isOver;
689
- }
690
- function PrologParserFactory$parseClauses$lambda_2(it) {
691
- return it.clause();
519
+ function TermParserImpl(scope, defaultOperatorSet, lexerOptions, parserOptions) {
520
+ lexerOptions = lexerOptions === VOID ? new LexerOptions() : lexerOptions;
521
+ parserOptions = parserOptions === VOID ? new ParserOptions() : parserOptions;
522
+ this.o3o_1 = scope;
523
+ this.p3o_1 = defaultOperatorSet;
524
+ this.q3o_1 = lexerOptions;
525
+ this.r3o_1 = parserOptions;
692
526
  }
693
- function PrologParserFactory() {
694
- }
695
- protoOf(PrologParserFactory).w38 = function (string, withOperators) {
696
- var parser = this.x38(string, withOperators);
697
- return parseExpression(this, parser, string);
698
- };
699
- protoOf(PrologParserFactory).y38 = function (source, withOperators) {
700
- var parser = this.x38(source, withOperators);
701
- return parseClauses(this, parser, source);
527
+ protoOf(TermParserImpl).n3o = function () {
528
+ return this.p3o_1;
702
529
  };
703
- protoOf(PrologParserFactory).x38 = function (source, operators) {
704
- var stream = new InputStream(source);
705
- var lexer = new PrologLexer(stream);
706
- lexer.removeErrorListeners();
707
- var tokenStream = new CommonTokenStream(lexer);
708
- var parser = new PrologParser(tokenStream);
709
- parser.removeErrorListeners();
710
- var originalErrorStrategy = parser._errHandler;
711
- parser._errHandler = new BailErrorStrategy();
712
- parser._interp.predictionMode = PredictionMode.SLL;
713
- return to(this.z38(parser, operators), originalErrorStrategy);
530
+ protoOf(TermParserImpl).s3o = function (input, operators) {
531
+ return buildParserFor(input, null, this.q3o_1, this.r3o_1, TermParserImpl$parseTerm$lambda(operators, this, input));
714
532
  };
715
- protoOf(PrologParserFactory).z38 = function (prologParser, operators) {
716
- // Inline function 'kotlin.collections.forEach' call
717
- var _iterator__ex2g4s = operators.p();
718
- while (_iterator__ex2g4s.s()) {
719
- var element = _iterator__ex2g4s.t();
720
- prologParser.addOperator(element.e1h_1, toAssociativity(element.f1h_1), element.g1h_1);
721
- }
722
- prologParser.addParseListener(Companion_instance_2.t38(prologParser));
723
- return prologParser;
533
+ protoOf(TermParserImpl).parseTermWithOperators = function (input, operators) {
534
+ return this.s3o(input, operators);
724
535
  };
725
- var PrologParserFactory_instance;
726
- function PrologParserFactory_getInstance() {
727
- return PrologParserFactory_instance;
728
- }
729
- function parseInteger_0($this, ctx) {
730
- var str = ctx.value.text;
731
- var base;
732
- var clean;
733
- if (ctx.isBin) {
734
- base = 2;
735
- clean = substring(str, 2);
736
- } else if (ctx.isOct) {
737
- base = 8;
738
- clean = substring(str, 2);
739
- } else if (ctx.isHex) {
740
- base = 16;
741
- clean = substring(str, 2);
742
- } else if (ctx.isChar) {
743
- clean = substring(str, 2);
744
- if (!(clean.length === 1)) {
745
- throw parseException(ctx.value, 'Invalid character literal: ' + ctx.value.text);
746
- }
747
- var tmp = Companion_getInstance_1();
748
- // Inline function 'kotlin.code' call
749
- var this_0 = charCodeAt(clean, 0);
750
- var tmp$ret$0 = Char__toInt_impl_vasixd(this_0);
751
- // Inline function 'kotlin.with' call
752
- var $this$with = tmp.of(tmp$ret$0);
753
- var tmp_0;
754
- var tmp0_safe_receiver = ctx.sign;
755
- var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text;
756
- var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : contains_0(tmp1_safe_receiver, '-');
757
- if (tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs) {
758
- tmp_0 = $this$with.unaryMinus();
759
- } else {
760
- tmp_0 = $this$with;
761
- }
762
- return tmp_0;
763
- } else {
764
- base = 10;
765
- clean = str;
766
- }
767
- if (!(ctx.sign == null)) {
768
- var tmp0_safe_receiver_0 = ctx.sign;
769
- clean = plus(tmp0_safe_receiver_0 == null ? null : tmp0_safe_receiver_0.text, clean);
770
- }
771
- return Companion_getInstance_1().parseWithRadix(clean, base);
772
- }
773
- function visitPostfixExpression($this, ctx) {
774
- var tmp0_safe_receiver = ctx.left;
775
- var tmp = ensureNotNull(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept($this));
776
- // Inline function 'kotlin.collections.map' call
777
- var this_0 = ctx.operators;
778
- // Inline function 'kotlin.collections.mapTo' call
779
- var destination = ArrayList_init_$Create$(this_0.length);
780
- var inductionVariable = 0;
781
- var last = this_0.length;
782
- while (inductionVariable < last) {
783
- var item = this_0[inductionVariable];
784
- inductionVariable = inductionVariable + 1 | 0;
785
- var tmp$ret$0 = item.symbol.text;
786
- destination.m(tmp$ret$0);
787
- }
788
- return postfix($this, tmp, destination);
789
- }
790
- function postfix($this, term, ops) {
791
- var operator = ops.p();
792
- var result = $this.a39_1.structOf(operator.t(), [term]);
793
- while (operator.s()) {
794
- result = $this.a39_1.structOf(operator.t(), [result]);
795
- }
796
- return result;
797
- }
798
- function visitPrefixExpression($this, ctx) {
799
- var tmp = ctx.right[0].accept($this);
800
- // Inline function 'kotlin.collections.map' call
801
- var this_0 = ctx.operators;
802
- // Inline function 'kotlin.collections.mapTo' call
803
- var destination = ArrayList_init_$Create$(this_0.length);
804
- var inductionVariable = 0;
805
- var last = this_0.length;
806
- while (inductionVariable < last) {
807
- var item = this_0[inductionVariable];
808
- inductionVariable = inductionVariable + 1 | 0;
809
- var tmp$ret$0 = item.symbol.text;
810
- destination.m(tmp$ret$0);
811
- }
812
- return prefix($this, tmp, destination);
813
- }
814
- function prefix($this, term, ops) {
815
- var i = ops.v() - 1 | 0;
816
- var _unary__edvuaz = i;
817
- i = _unary__edvuaz - 1 | 0;
818
- var result = $this.a39_1.structOf(ops.w(_unary__edvuaz), [term]);
819
- while (i >= 0) {
820
- result = $this.a39_1.structOf(ops.w(i), [result]);
821
- i = i - 1 | 0;
822
- }
823
- return result;
824
- }
825
- function visitInfixExpression($this, ctx) {
826
- var tmp0_subject = ctx.associativity;
827
- var tmp;
828
- if (tmp0_subject === Associativity.XFY) {
829
- tmp = visitInfixRightAssociativeExpression($this, ctx);
830
- } else if (tmp0_subject === Associativity.YFX) {
831
- tmp = visitInfixLeftAssociativeExpression($this, ctx);
832
- } else if (tmp0_subject === Associativity.XFX) {
833
- tmp = visitInfixNonAssociativeExpression($this, ctx);
834
- } else {
835
- var message = 'Non-infix associativity ' + ctx.associativity + ' in infix expression';
836
- throw IllegalStateException_init_$Create$(toString_0(message));
837
- }
838
- return tmp;
839
- }
840
- function visitInfixNonAssociativeExpression($this, ctx) {
841
- // Inline function 'kotlin.collections.map' call
842
- var this_0 = plus_0(listOf(ensureNotNull(ctx.left)), asList(ctx.right));
843
- // Inline function 'kotlin.collections.mapTo' call
844
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
845
- var _iterator__ex2g4s = this_0.p();
846
- while (_iterator__ex2g4s.s()) {
847
- var item = _iterator__ex2g4s.t();
848
- var tmp$ret$0 = item.accept($this);
849
- destination.m(tmp$ret$0);
850
- }
851
- var operands = destination;
536
+ function toOperatorTable(_this__u8e3s4) {
537
+ var tmp = OperatorTables_instance;
852
538
  // Inline function 'kotlin.collections.map' call
853
- var this_1 = ctx.operators;
854
539
  // Inline function 'kotlin.collections.mapTo' call
855
- var destination_0 = ArrayList_init_$Create$(this_1.length);
856
- var inductionVariable = 0;
857
- var last = this_1.length;
858
- while (inductionVariable < last) {
859
- var item_0 = this_1[inductionVariable];
860
- inductionVariable = inductionVariable + 1 | 0;
861
- var tmp$ret$3 = item_0.symbol.text;
862
- destination_0.m(tmp$ret$3);
863
- }
864
- var operators = destination_0;
865
- return infixNonAssociative($this, operands, operators);
866
- }
867
- function infixNonAssociative($this, terms, ops) {
868
- return $this.a39_1.structOf(ops.w(0), [terms.w(0), terms.w(1)]);
869
- }
870
- function handleOuters($this, expression, outers) {
871
- var result = expression;
872
- var _iterator__ex2g4s = outers.p();
873
- while (_iterator__ex2g4s.s()) {
874
- var o = _iterator__ex2g4s.t();
875
- var tmp = listOf(result);
876
- // Inline function 'kotlin.collections.map' call
877
- var this_0 = o.right;
878
- // Inline function 'kotlin.collections.mapTo' call
879
- var destination = ArrayList_init_$Create$(this_0.length);
880
- var inductionVariable = 0;
881
- var last = this_0.length;
882
- while (inductionVariable < last) {
883
- var item = this_0[inductionVariable];
884
- inductionVariable = inductionVariable + 1 | 0;
885
- var tmp$ret$0 = item.accept($this);
886
- destination.m(tmp$ret$0);
887
- }
888
- var operands = plus_0(tmp, destination);
889
- // Inline function 'kotlin.collections.map' call
890
- var this_1 = o.operators;
891
- // Inline function 'kotlin.collections.mapTo' call
892
- var destination_0 = ArrayList_init_$Create$(this_1.length);
893
- var inductionVariable_0 = 0;
894
- var last_0 = this_1.length;
895
- while (inductionVariable_0 < last_0) {
896
- var item_0 = this_1[inductionVariable_0];
897
- inductionVariable_0 = inductionVariable_0 + 1 | 0;
898
- var tmp$ret$3 = item_0.symbol.text;
899
- destination_0.m(tmp$ret$3);
900
- }
901
- var operators = destination_0;
902
- var associativity = o.associativity;
903
- var tmp_0;
904
- if (associativity === Associativity.XFY) {
905
- tmp_0 = infixRight($this, operands, operators);
906
- } else if (associativity === Associativity.XF || associativity === Associativity.YF) {
907
- tmp_0 = postfix($this, result, operators);
908
- } else if (associativity === Associativity.XFX) {
909
- tmp_0 = infixNonAssociative($this, operands, operators);
910
- } else if (associativity === Associativity.YFX) {
911
- tmp_0 = infixLeft($this, operands, operators);
912
- } else if (associativity === Associativity.FX || associativity === Associativity.FY) {
913
- tmp_0 = prefix($this, result, operators);
914
- } else {
915
- var message = 'Invalid associativity: ' + associativity;
916
- throw IllegalStateException_init_$Create$(toString_0(message));
917
- }
918
- result = tmp_0;
540
+ var destination = ArrayList_init_$Create$(collectionSizeOrDefault(_this__u8e3s4, 10));
541
+ var _iterator__ex2g4s = _this__u8e3s4.n();
542
+ while (_iterator__ex2g4s.q()) {
543
+ var item = _iterator__ex2g4s.r();
544
+ var tmp$ret$2 = toDefinition(item);
545
+ destination.k(tmp$ret$2);
919
546
  }
920
- return result;
547
+ return tmp.y3m(destination);
921
548
  }
922
- function infixRight($this, terms, ops) {
923
- var i = terms.v() - 1 | 0;
924
- var j = ops.v() - 1 | 0;
925
- var _unary__edvuaz = j;
926
- j = _unary__edvuaz - 1 | 0;
927
- var result = $this.a39_1.structOf(ops.w(_unary__edvuaz), [terms.w(i - 1 | 0), terms.w(i)]);
928
- i = i - 2 | 0;
929
- while (i >= 0) {
930
- var _unary__edvuaz_0 = j;
931
- j = _unary__edvuaz_0 - 1 | 0;
932
- result = $this.a39_1.structOf(ops.w(_unary__edvuaz_0), [terms.w(i), result]);
933
- i = i - 1 | 0;
934
- }
935
- return result;
549
+ function toDefinition(_this__u8e3s4) {
550
+ return new OperatorDefinition(_this__u8e3s4.h1i_1, toAssociativity(_this__u8e3s4.i1i_1), _this__u8e3s4.j1i_1);
936
551
  }
937
- function infixLeft($this, terms, ops) {
938
- var i = 0;
939
- var j = 0;
940
- var _unary__edvuaz = j;
941
- j = _unary__edvuaz + 1 | 0;
942
- var tmp = ops.w(_unary__edvuaz);
943
- var _unary__edvuaz_0 = i;
944
- i = _unary__edvuaz_0 + 1 | 0;
945
- var tmp_0 = terms.w(_unary__edvuaz_0);
946
- var _unary__edvuaz_1 = i;
947
- i = _unary__edvuaz_1 + 1 | 0;
948
- var result = $this.a39_1.structOf(tmp, [tmp_0, terms.w(_unary__edvuaz_1)]);
949
- while (i < terms.v()) {
950
- var _unary__edvuaz_2 = j;
951
- j = _unary__edvuaz_2 + 1 | 0;
952
- result = $this.a39_1.structOf(ops.w(_unary__edvuaz_2), [result, terms.w(i)]);
953
- i = i + 1 | 0;
954
- }
955
- return result;
956
- }
957
- function listOfOperands($this, ctx) {
958
- // Inline function 'kotlin.collections.map' call
959
- var this_0 = plus_0(listOf(ctx.left), toList(ctx.right));
960
- // Inline function 'kotlin.collections.mapTo' call
961
- var destination = ArrayList_init_$Create$(collectionSizeOrDefault(this_0, 10));
962
- var _iterator__ex2g4s = this_0.p();
963
- while (_iterator__ex2g4s.s()) {
964
- var item = _iterator__ex2g4s.t();
965
- var tmp$ret$0 = ensureNotNull(item).accept($this);
966
- destination.m(tmp$ret$0);
967
- }
968
- return destination;
969
- }
970
- function listOfOperators($this, ctx) {
971
- // Inline function 'kotlin.collections.map' call
972
- var this_0 = ctx.operators;
973
- // Inline function 'kotlin.collections.mapTo' call
974
- var destination = ArrayList_init_$Create$(this_0.length);
975
- var inductionVariable = 0;
976
- var last = this_0.length;
977
- while (inductionVariable < last) {
978
- var item = this_0[inductionVariable];
979
- inductionVariable = inductionVariable + 1 | 0;
980
- var tmp$ret$0 = item.symbol.text;
981
- destination.m(tmp$ret$0);
982
- }
983
- return destination;
984
- }
985
- function visitInfixRightAssociativeExpression($this, ctx) {
986
- return infixRight($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
987
- }
988
- function visitInfixLeftAssociativeExpression($this, ctx) {
989
- return infixLeft($this, listOfOperands($this, ctx), listOfOperators($this, ctx));
990
- }
991
- function flatten($this, outers) {
992
- // Inline function 'kotlin.sequences.asSequence' call
993
- var tmp = outers;
994
- return flatMap(tmp, PrologVisitor$flatten$lambda($this));
995
- }
996
- function flatten_0($this, outers) {
997
- return toList_0(flatten($this, asSequence(outers)));
998
- }
999
- function PrologVisitor$visitExpression$ref(p0) {
1000
- var l = function (_this__u8e3s4) {
1001
- return p0.b39(_this__u8e3s4);
1002
- };
1003
- l.callableName = 'visitExpression';
1004
- return l;
1005
- }
1006
- function PrologVisitor$flatten$lambda(this$0) {
1007
- return function (it) {
1008
- return plus_1(sequenceOf(it), flatten(this$0, asSequence_0(it.outers)));
1009
- };
1010
- }
1011
- function PrologVisitor(scope) {
1012
- scope = scope === VOID ? Companion_instance.empty() : scope;
1013
- PrologParserVisitor.call(this);
1014
- this.a39_1 = scope;
1015
- }
1016
- protoOf(PrologVisitor).c39 = function (ctx) {
1017
- return this.d39(ctx.term());
1018
- };
1019
- protoOf(PrologVisitor).visitSingletonTerm = function (ctx) {
1020
- return this.c39(ctx);
1021
- };
1022
- protoOf(PrologVisitor).e39 = function (ctx) {
1023
- return this.b39(ctx.expression());
1024
- };
1025
- protoOf(PrologVisitor).visitSingletonExpression = function (ctx) {
1026
- return this.e39(ctx);
1027
- };
1028
- protoOf(PrologVisitor).f39 = function (ctx) {
1029
- return termToClause(ctx.expression().accept(this), null, ensureNotNull(ctx.start).line, ensureNotNull(ctx.start).column);
1030
- };
1031
- protoOf(PrologVisitor).visitClause = function (ctx) {
1032
- return this.f39(ctx);
1033
- };
1034
- protoOf(PrologVisitor).b39 = function (ctx) {
1035
- var tmp;
1036
- if (ctx.isTerm) {
1037
- tmp = this.d39(ensureNotNull(ctx.left));
1038
- } else if (contains(Associativity.INFIX, ctx.associativity)) {
1039
- tmp = visitInfixExpression(this, ctx);
1040
- } else if (contains(Associativity.POSTFIX, ctx.associativity)) {
1041
- tmp = visitPostfixExpression(this, ctx);
1042
- } else if (contains(Associativity.PREFIX, ctx.associativity)) {
1043
- tmp = visitPrefixExpression(this, ctx);
1044
- } else {
1045
- throw IllegalArgumentException_init_$Create$('Associativity unknown: ' + ctx.associativity + ' INFIX=' + toString_0(Associativity.INFIX) + ' PREFIX=' + toString_0(Associativity.PREFIX) + ' POSTFIX=' + toString_0(Associativity.POSTFIX));
1046
- }
1047
- return handleOuters(this, tmp, flatten_0(this, asList(ctx.outers)));
1048
- };
1049
- protoOf(PrologVisitor).visitExpression = function (ctx) {
1050
- return this.b39(ctx);
1051
- };
1052
- protoOf(PrologVisitor).d39 = function (ctx) {
1053
- var tmp;
1054
- if (ctx.isExpr) {
1055
- tmp = this.b39(ctx.expression());
1056
- } else {
1057
- var tmp_0 = ctx.children[0].accept(this);
1058
- tmp = (!(tmp_0 == null) ? isInterface(tmp_0, Term) : false) ? tmp_0 : THROW_CCE();
1059
- }
1060
- return tmp;
1061
- };
1062
- protoOf(PrologVisitor).visitTerm = function (ctx) {
1063
- return this.d39(ctx);
1064
- };
1065
- protoOf(PrologVisitor).g39 = function (ctx) {
1066
- var value = parseInteger_0(this, ctx);
1067
- return Companion_getInstance_2().ofBigInteger(value);
1068
- };
1069
- protoOf(PrologVisitor).visitInteger = function (ctx) {
1070
- return this.g39(ctx);
1071
- };
1072
- protoOf(PrologVisitor).h39 = function (ctx) {
1073
- var tmp = ctx.children[0].accept(this);
1074
- return (!(tmp == null) ? isInterface(tmp, Term) : false) ? tmp : THROW_CCE();
1075
- };
1076
- protoOf(PrologVisitor).visitNumber = function (ctx) {
1077
- return this.h39(ctx);
1078
- };
1079
- protoOf(PrologVisitor).i39 = function (ctx) {
1080
- var raw = ctx.value.text;
1081
- if (!(ctx.sign == null)) {
1082
- var tmp0_safe_receiver = ctx.sign;
1083
- raw = plus(tmp0_safe_receiver == null ? null : tmp0_safe_receiver.text, raw);
1084
- }
1085
- var tmp;
1086
- try {
1087
- tmp = Companion_getInstance_3().parse(raw);
1088
- } catch ($p) {
1089
- var tmp_0;
1090
- if ($p instanceof NumberFormatException) {
1091
- var notAFloating = $p;
1092
- throw parseException(ctx.value, 'Invalid real number format: ' + ctx.value.text);
1093
- } else {
1094
- throw $p;
1095
- }
1096
- }
1097
- return tmp;
1098
- };
1099
- protoOf(PrologVisitor).visitReal = function (ctx) {
1100
- return this.i39(ctx);
1101
- };
1102
- protoOf(PrologVisitor).j39 = function (ctx) {
1103
- var tmp;
1104
- if (ctx.isAnonymous) {
1105
- tmp = this.a39_1.anonymous();
1106
- } else {
1107
- tmp = this.a39_1.varOf(ctx.value.text);
1108
- }
1109
- return tmp;
1110
- };
1111
- protoOf(PrologVisitor).visitVariable = function (ctx) {
1112
- return this.j39(ctx);
1113
- };
1114
- protoOf(PrologVisitor).k39 = function (ctx) {
1115
- var tmp;
1116
- if (ctx.isList) {
1117
- tmp = this.a39_1.logicListOf([]);
1118
- } else if (ctx.isBlock) {
1119
- tmp = this.a39_1.blockOf([]);
1120
- } else if (ctx.arity === 0) {
1121
- tmp = this.a39_1.atomOf(ctx.functor.text);
1122
- } else {
1123
- var tmp_0 = ctx.functor.text;
1124
- var tmp_1 = asSequence_0(ctx.args);
1125
- tmp = this.a39_1.structOfSequence(tmp_0, map(tmp_1, PrologVisitor$visitExpression$ref(this)));
1126
- }
1127
- return tmp;
1128
- };
1129
- protoOf(PrologVisitor).visitStructure = function (ctx) {
1130
- return this.k39(ctx);
1131
- };
1132
- protoOf(PrologVisitor).l39 = function (ctx) {
1133
- // Inline function 'kotlin.collections.map' call
1134
- var this_0 = ctx.items;
1135
- // Inline function 'kotlin.collections.mapTo' call
1136
- var destination = ArrayList_init_$Create$(this_0.length);
1137
- var inductionVariable = 0;
1138
- var last = this_0.length;
1139
- while (inductionVariable < last) {
1140
- var item = this_0[inductionVariable];
1141
- inductionVariable = inductionVariable + 1 | 0;
1142
- var tmp$ret$0 = this.b39(item);
1143
- destination.m(tmp$ret$0);
1144
- }
1145
- var terms = destination;
1146
- var tmp;
1147
- if (ctx.hasTail) {
1148
- var tmp0_safe_receiver = ctx.tail;
1149
- tmp = this.a39_1.w10(terms, tmp0_safe_receiver == null ? null : tmp0_safe_receiver.accept(this));
1150
- } else {
1151
- tmp = this.a39_1.logicListOfIterable(terms);
1152
- }
1153
- return tmp;
1154
- };
1155
- protoOf(PrologVisitor).visitList = function (ctx) {
1156
- return this.l39(ctx);
1157
- };
1158
- protoOf(PrologVisitor).m39 = function (ctx) {
552
+ function toAssociativity(_this__u8e3s4) {
1159
553
  var tmp;
1160
- if (ctx.length === 1) {
1161
- tmp = this.a39_1.blockOf([ctx.items[0].accept(this)]);
1162
- } else {
1163
- // Inline function 'kotlin.collections.map' call
1164
- var this_0 = ctx.items;
1165
- // Inline function 'kotlin.collections.mapTo' call
1166
- var destination = ArrayList_init_$Create$(this_0.length);
1167
- var inductionVariable = 0;
1168
- var last = this_0.length;
1169
- while (inductionVariable < last) {
1170
- var item = this_0[inductionVariable];
1171
- inductionVariable = inductionVariable + 1 | 0;
1172
- var tmp$ret$0 = this.b39(item);
1173
- destination.m(tmp$ret$0);
1174
- }
1175
- tmp = this.a39_1.blockOfIterable(destination);
554
+ switch (_this__u8e3s4.m2_1) {
555
+ case 2:
556
+ tmp = Associativity_FX_getInstance();
557
+ break;
558
+ case 3:
559
+ tmp = Associativity_FY_getInstance();
560
+ break;
561
+ case 0:
562
+ tmp = Associativity_XF_getInstance();
563
+ break;
564
+ case 1:
565
+ tmp = Associativity_YF_getInstance();
566
+ break;
567
+ case 4:
568
+ tmp = Associativity_XFX_getInstance();
569
+ break;
570
+ case 6:
571
+ tmp = Associativity_YFX_getInstance();
572
+ break;
573
+ case 5:
574
+ tmp = Associativity_XFY_getInstance();
575
+ break;
576
+ default:
577
+ noWhenBranchMatchedException();
578
+ break;
1176
579
  }
1177
580
  return tmp;
1178
- };
1179
- protoOf(PrologVisitor).visitBlock = function (ctx) {
1180
- return this.m39(ctx);
1181
- };
1182
- function termParserWithOperators(operators, scope) {
1183
- scope = scope === VOID ? Companion_instance.empty() : scope;
1184
- return new TermParserImpl(scope, operators);
1185
581
  }
1186
- function TermParserImpl(scope, defaultOperatorSet) {
1187
- this.n39_1 = scope;
1188
- this.o39_1 = defaultOperatorSet;
582
+ function toParseException(_this__u8e3s4, input) {
583
+ return new ParseException(input, _this__u8e3s4.c3d_1, _this__u8e3s4.b3d_1.b3b_1.z3a_1 + 1 | 0, _this__u8e3s4.b3d_1.b3b_1.a3b_1 + 1 | 0, _this__u8e3s4.message, _this__u8e3s4);
1189
584
  }
1190
- protoOf(TermParserImpl).q38 = function () {
1191
- return this.o39_1;
1192
- };
1193
- protoOf(TermParserImpl).p39 = function (input, operators) {
1194
- return PrologParserFactory_instance.w38(input, operators).accept(new PrologVisitor(this.n39_1));
1195
- };
1196
- protoOf(TermParserImpl).parseTermWithOperators = function (input, operators) {
1197
- return this.p39(input, operators);
1198
- };
1199
585
  //region block: post-declaration
586
+ protoOf(PrologTermParserVisitor).o3n = visit;
587
+ protoOf(PrologTermParserVisitor).f3n = visitExpression;
588
+ protoOf(PrologTermParserVisitor).e3n = visitClause;
589
+ protoOf(PrologTermParserVisitor).q3n = visitTerm;
590
+ protoOf(PrologTermParserVisitor).m3n = visitParenthesizedExpression;
1200
591
  protoOf(TermParserImpl).parseTerm = parseTerm;
1201
592
  protoOf(TermParserImpl).parseStructWithOperators = parseStructWithOperators;
1202
593
  protoOf(TermParserImpl).parseStruct = parseStruct;
@@ -1223,18 +614,18 @@
1223
614
  //endregion
1224
615
  //region block: init
1225
616
  Companion_instance_1 = new Companion();
1226
- Companion_instance_2 = new Companion_0();
1227
- PrologParserFactory_instance = new PrologParserFactory();
1228
617
  //endregion
1229
618
  //region block: exports
1230
619
  _.$_$ = _.$_$ || {};
1231
- _.$_$.a = PrologParserFactory_instance;
1232
- _.$_$.b = PrologVisitor;
620
+ _.$_$.a = ParseException;
621
+ _.$_$.b = PrologTermParserVisitor;
1233
622
  _.$_$.c = parseClause_0;
1234
623
  _.$_$.d = parseStruct_0;
1235
624
  _.$_$.e = parseTerm_0;
1236
625
  _.$_$.f = parseStructWithOperators_0;
1237
626
  _.$_$.g = termToClause;
627
+ _.$_$.h = toDefinition;
628
+ _.$_$.i = toOperatorTable;
1238
629
  //endregion
1239
630
  return _;
1240
631
  }));