@irrelon/battlescript 3.2.1 → 3.2.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.
@@ -1,5 +1,6 @@
1
1
  import require$$0 from 'assert';
2
2
  import require$$0$1 from 'util';
3
+ import { CharStreams as CharStreams$1, CommonTokenStream as CommonTokenStream$1 } from 'antlr4ts';
3
4
  import { join, dirname } from 'path';
4
5
 
5
6
  var EnumNodeLayoutEntry;
@@ -30793,1351 +30794,6 @@ class BattleScriptMiniAstInterpreter {
30793
30794
  }
30794
30795
  }
30795
30796
 
30796
- var antlr4ts = {};
30797
-
30798
- var ANTLRErrorListener = {};
30799
-
30800
- var hasRequiredANTLRErrorListener;
30801
-
30802
- function requireANTLRErrorListener () {
30803
- if (hasRequiredANTLRErrorListener) return ANTLRErrorListener;
30804
- hasRequiredANTLRErrorListener = 1;
30805
- /*!
30806
- * Copyright 2016 The ANTLR Project. All rights reserved.
30807
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30808
- */
30809
- Object.defineProperty(ANTLRErrorListener, "__esModule", { value: true });
30810
-
30811
- return ANTLRErrorListener;
30812
- }
30813
-
30814
- var ANTLRErrorStrategy = {};
30815
-
30816
- var hasRequiredANTLRErrorStrategy;
30817
-
30818
- function requireANTLRErrorStrategy () {
30819
- if (hasRequiredANTLRErrorStrategy) return ANTLRErrorStrategy;
30820
- hasRequiredANTLRErrorStrategy = 1;
30821
- /*!
30822
- * Copyright 2016 The ANTLR Project. All rights reserved.
30823
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30824
- */
30825
- Object.defineProperty(ANTLRErrorStrategy, "__esModule", { value: true });
30826
-
30827
- return ANTLRErrorStrategy;
30828
- }
30829
-
30830
- var ANTLRInputStream = {};
30831
-
30832
- var hasRequiredANTLRInputStream;
30833
-
30834
- function requireANTLRInputStream () {
30835
- if (hasRequiredANTLRInputStream) return ANTLRInputStream;
30836
- hasRequiredANTLRInputStream = 1;
30837
- /*!
30838
- * Copyright 2016 The ANTLR Project. All rights reserved.
30839
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30840
- */
30841
- // ConvertTo-TS run at 2016-10-04T11:26:49.0828748-07:00
30842
- var __decorate = (ANTLRInputStream && ANTLRInputStream.__decorate) || function (decorators, target, key, desc) {
30843
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30844
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30845
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30846
- return c > 3 && r && Object.defineProperty(target, key, r), r;
30847
- };
30848
- Object.defineProperty(ANTLRInputStream, "__esModule", { value: true });
30849
- ANTLRInputStream.ANTLRInputStream = void 0;
30850
- const assert = require$$0;
30851
- const Decorators_1 = requireDecorators();
30852
- const IntStream_1 = requireIntStream();
30853
- /**
30854
- * Vacuum all input from a {@link Reader}/{@link InputStream} and then treat it
30855
- * like a `char[]` buffer. Can also pass in a {@link String} or
30856
- * `char[]` to use.
30857
- *
30858
- * If you need encoding, pass in stream/reader with correct encoding.
30859
- *
30860
- * @deprecated as of 4.7, please use `CharStreams` interface.
30861
- */
30862
- let ANTLRInputStream$1 = class ANTLRInputStream {
30863
- /** Copy data in string to a local char array */
30864
- constructor(input) {
30865
- /** 0..n-1 index into string of next char */
30866
- this.p = 0;
30867
- this.data = input;
30868
- this.n = input.length;
30869
- }
30870
- /** Reset the stream so that it's in the same state it was
30871
- * when the object was created *except* the data array is not
30872
- * touched.
30873
- */
30874
- reset() {
30875
- this.p = 0;
30876
- }
30877
- consume() {
30878
- if (this.p >= this.n) {
30879
- assert(this.LA(1) === IntStream_1.IntStream.EOF);
30880
- throw new Error("cannot consume EOF");
30881
- }
30882
- //System.out.println("prev p="+p+", c="+(char)data[p]);
30883
- if (this.p < this.n) {
30884
- this.p++;
30885
- //System.out.println("p moves to "+p+" (c='"+(char)data[p]+"')");
30886
- }
30887
- }
30888
- LA(i) {
30889
- if (i === 0) {
30890
- return 0; // undefined
30891
- }
30892
- if (i < 0) {
30893
- i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
30894
- if ((this.p + i - 1) < 0) {
30895
- return IntStream_1.IntStream.EOF; // invalid; no char before first char
30896
- }
30897
- }
30898
- if ((this.p + i - 1) >= this.n) {
30899
- //System.out.println("char LA("+i+")=EOF; p="+p);
30900
- return IntStream_1.IntStream.EOF;
30901
- }
30902
- //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p);
30903
- //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length);
30904
- return this.data.charCodeAt(this.p + i - 1);
30905
- }
30906
- LT(i) {
30907
- return this.LA(i);
30908
- }
30909
- /** Return the current input symbol index 0..n where n indicates the
30910
- * last symbol has been read. The index is the index of char to
30911
- * be returned from LA(1).
30912
- */
30913
- get index() {
30914
- return this.p;
30915
- }
30916
- get size() {
30917
- return this.n;
30918
- }
30919
- /** mark/release do nothing; we have entire buffer */
30920
- mark() {
30921
- return -1;
30922
- }
30923
- release(marker) {
30924
- // No default implementation since this stream buffers the entire input
30925
- }
30926
- /** consume() ahead until p==index; can't just set p=index as we must
30927
- * update line and charPositionInLine. If we seek backwards, just set p
30928
- */
30929
- seek(index) {
30930
- if (index <= this.p) {
30931
- this.p = index; // just jump; don't update stream state (line, ...)
30932
- return;
30933
- }
30934
- // seek forward, consume until p hits index or n (whichever comes first)
30935
- index = Math.min(index, this.n);
30936
- while (this.p < index) {
30937
- this.consume();
30938
- }
30939
- }
30940
- getText(interval) {
30941
- let start = interval.a;
30942
- let stop = interval.b;
30943
- if (stop >= this.n) {
30944
- stop = this.n - 1;
30945
- }
30946
- let count = stop - start + 1;
30947
- if (start >= this.n) {
30948
- return "";
30949
- }
30950
- // System.err.println("data: "+Arrays.toString(data)+", n="+n+
30951
- // ", start="+start+
30952
- // ", stop="+stop);
30953
- return this.data.substr(start, count);
30954
- }
30955
- get sourceName() {
30956
- if (!this.name) {
30957
- return IntStream_1.IntStream.UNKNOWN_SOURCE_NAME;
30958
- }
30959
- return this.name;
30960
- }
30961
- toString() { return this.data; }
30962
- };
30963
- __decorate([
30964
- Decorators_1.Override
30965
- ], ANTLRInputStream$1.prototype, "consume", null);
30966
- __decorate([
30967
- Decorators_1.Override
30968
- ], ANTLRInputStream$1.prototype, "LA", null);
30969
- __decorate([
30970
- Decorators_1.Override
30971
- ], ANTLRInputStream$1.prototype, "index", null);
30972
- __decorate([
30973
- Decorators_1.Override
30974
- ], ANTLRInputStream$1.prototype, "size", null);
30975
- __decorate([
30976
- Decorators_1.Override
30977
- ], ANTLRInputStream$1.prototype, "mark", null);
30978
- __decorate([
30979
- Decorators_1.Override
30980
- ], ANTLRInputStream$1.prototype, "release", null);
30981
- __decorate([
30982
- Decorators_1.Override
30983
- ], ANTLRInputStream$1.prototype, "seek", null);
30984
- __decorate([
30985
- Decorators_1.Override
30986
- ], ANTLRInputStream$1.prototype, "getText", null);
30987
- __decorate([
30988
- Decorators_1.Override
30989
- ], ANTLRInputStream$1.prototype, "sourceName", null);
30990
- __decorate([
30991
- Decorators_1.Override
30992
- ], ANTLRInputStream$1.prototype, "toString", null);
30993
- ANTLRInputStream.ANTLRInputStream = ANTLRInputStream$1;
30994
-
30995
- return ANTLRInputStream;
30996
- }
30997
-
30998
- var CharStream = {};
30999
-
31000
- var hasRequiredCharStream;
31001
-
31002
- function requireCharStream () {
31003
- if (hasRequiredCharStream) return CharStream;
31004
- hasRequiredCharStream = 1;
31005
- /*!
31006
- * Copyright 2016 The ANTLR Project. All rights reserved.
31007
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31008
- */
31009
- Object.defineProperty(CharStream, "__esModule", { value: true });
31010
-
31011
- return CharStream;
31012
- }
31013
-
31014
- var Dependents = {};
31015
-
31016
- var hasRequiredDependents;
31017
-
31018
- function requireDependents () {
31019
- if (hasRequiredDependents) return Dependents;
31020
- hasRequiredDependents = 1;
31021
- (function (exports) {
31022
- /*!
31023
- * Copyright 2016 The ANTLR Project. All rights reserved.
31024
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31025
- */
31026
- Object.defineProperty(exports, "__esModule", { value: true });
31027
- exports.Dependents = void 0;
31028
- (function (Dependents) {
31029
- /**
31030
- * The element is dependent upon the specified rule.
31031
- */
31032
- Dependents[Dependents["SELF"] = 0] = "SELF";
31033
- /**
31034
- * The element is dependent upon the set of the specified rule's parents
31035
- * (rules which directly reference it).
31036
- */
31037
- Dependents[Dependents["PARENTS"] = 1] = "PARENTS";
31038
- /**
31039
- * The element is dependent upon the set of the specified rule's children
31040
- * (rules which it directly references).
31041
- */
31042
- Dependents[Dependents["CHILDREN"] = 2] = "CHILDREN";
31043
- /**
31044
- * The element is dependent upon the set of the specified rule's ancestors
31045
- * (the transitive closure of `PARENTS` rules).
31046
- */
31047
- Dependents[Dependents["ANCESTORS"] = 3] = "ANCESTORS";
31048
- /**
31049
- * The element is dependent upon the set of the specified rule's descendants
31050
- * (the transitive closure of `CHILDREN` rules).
31051
- */
31052
- Dependents[Dependents["DESCENDANTS"] = 4] = "DESCENDANTS";
31053
- /**
31054
- * The element is dependent upon the set of the specified rule's siblings
31055
- * (the union of `CHILDREN` of its `PARENTS`).
31056
- */
31057
- Dependents[Dependents["SIBLINGS"] = 5] = "SIBLINGS";
31058
- /**
31059
- * The element is dependent upon the set of the specified rule's preceeding
31060
- * siblings (the union of `CHILDREN` of its `PARENTS` which
31061
- * appear before a reference to the rule).
31062
- */
31063
- Dependents[Dependents["PRECEEDING_SIBLINGS"] = 6] = "PRECEEDING_SIBLINGS";
31064
- /**
31065
- * The element is dependent upon the set of the specified rule's following
31066
- * siblings (the union of `CHILDREN` of its `PARENTS` which
31067
- * appear after a reference to the rule).
31068
- */
31069
- Dependents[Dependents["FOLLOWING_SIBLINGS"] = 7] = "FOLLOWING_SIBLINGS";
31070
- /**
31071
- * The element is dependent upon the set of the specified rule's preceeding
31072
- * elements (rules which might end before the start of the specified rule
31073
- * while parsing). This is calculated by taking the
31074
- * `PRECEEDING_SIBLINGS` of the rule and each of its
31075
- * `ANCESTORS`, along with the `DESCENDANTS` of those
31076
- * elements.
31077
- */
31078
- Dependents[Dependents["PRECEEDING"] = 8] = "PRECEEDING";
31079
- /**
31080
- * The element is dependent upon the set of the specified rule's following
31081
- * elements (rules which might start after the end of the specified rule
31082
- * while parsing). This is calculated by taking the
31083
- * `FOLLOWING_SIBLINGS` of the rule and each of its
31084
- * `ANCESTORS`, along with the `DESCENDANTS` of those
31085
- * elements.
31086
- */
31087
- Dependents[Dependents["FOLLOWING"] = 9] = "FOLLOWING";
31088
- })(exports.Dependents || (exports.Dependents = {}));
31089
-
31090
- } (Dependents));
31091
- return Dependents;
31092
- }
31093
-
31094
- var DiagnosticErrorListener = {};
31095
-
31096
- var hasRequiredDiagnosticErrorListener;
31097
-
31098
- function requireDiagnosticErrorListener () {
31099
- if (hasRequiredDiagnosticErrorListener) return DiagnosticErrorListener;
31100
- hasRequiredDiagnosticErrorListener = 1;
31101
- /*!
31102
- * Copyright 2016 The ANTLR Project. All rights reserved.
31103
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31104
- */
31105
- var __decorate = (DiagnosticErrorListener && DiagnosticErrorListener.__decorate) || function (decorators, target, key, desc) {
31106
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31107
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31108
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31109
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31110
- };
31111
- var __param = (DiagnosticErrorListener && DiagnosticErrorListener.__param) || function (paramIndex, decorator) {
31112
- return function (target, key) { decorator(target, key, paramIndex); }
31113
- };
31114
- Object.defineProperty(DiagnosticErrorListener, "__esModule", { value: true });
31115
- DiagnosticErrorListener.DiagnosticErrorListener = void 0;
31116
- const BitSet_1 = requireBitSet();
31117
- const Decorators_1 = requireDecorators();
31118
- const Interval_1 = requireInterval();
31119
- /**
31120
- * This implementation of {@link ANTLRErrorListener} can be used to identify
31121
- * certain potential correctness and performance problems in grammars. "Reports"
31122
- * are made by calling {@link Parser#notifyErrorListeners} with the appropriate
31123
- * message.
31124
- *
31125
- * * **Ambiguities**: These are cases where more than one path through the
31126
- * grammar can match the input.
31127
- * * **Weak context sensitivity**: These are cases where full-context
31128
- * prediction resolved an SLL conflict to a unique alternative which equaled the
31129
- * minimum alternative of the SLL conflict.
31130
- * * **Strong (forced) context sensitivity**: These are cases where the
31131
- * full-context prediction resolved an SLL conflict to a unique alternative,
31132
- * *and* the minimum alternative of the SLL conflict was found to not be
31133
- * a truly viable alternative. Two-stage parsing cannot be used for inputs where
31134
- * this situation occurs.
31135
- *
31136
- * @author Sam Harwell
31137
- */
31138
- let DiagnosticErrorListener$1 = class DiagnosticErrorListener {
31139
- /**
31140
- * Initializes a new instance of {@link DiagnosticErrorListener}, specifying
31141
- * whether all ambiguities or only exact ambiguities are reported.
31142
- *
31143
- * @param exactOnly `true` to report only exact ambiguities, otherwise
31144
- * `false` to report all ambiguities. Defaults to true.
31145
- */
31146
- constructor(exactOnly = true) {
31147
- this.exactOnly = exactOnly;
31148
- this.exactOnly = exactOnly;
31149
- }
31150
- syntaxError(
31151
- /*@NotNull*/
31152
- recognizer, offendingSymbol, line, charPositionInLine,
31153
- /*@NotNull*/
31154
- msg, e) {
31155
- // intentionally empty
31156
- }
31157
- reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) {
31158
- if (this.exactOnly && !exact) {
31159
- return;
31160
- }
31161
- let decision = this.getDecisionDescription(recognizer, dfa);
31162
- let conflictingAlts = this.getConflictingAlts(ambigAlts, configs);
31163
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
31164
- let message = `reportAmbiguity d=${decision}: ambigAlts=${conflictingAlts}, input='${text}'`;
31165
- recognizer.notifyErrorListeners(message);
31166
- }
31167
- reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, conflictState) {
31168
- let decision = this.getDecisionDescription(recognizer, dfa);
31169
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
31170
- let message = `reportAttemptingFullContext d=${decision}, input='${text}'`;
31171
- recognizer.notifyErrorListeners(message);
31172
- }
31173
- reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, acceptState) {
31174
- let decision = this.getDecisionDescription(recognizer, dfa);
31175
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
31176
- let message = `reportContextSensitivity d=${decision}, input='${text}'`;
31177
- recognizer.notifyErrorListeners(message);
31178
- }
31179
- getDecisionDescription(recognizer, dfa) {
31180
- let decision = dfa.decision;
31181
- let ruleIndex = dfa.atnStartState.ruleIndex;
31182
- let ruleNames = recognizer.ruleNames;
31183
- if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
31184
- return decision.toString();
31185
- }
31186
- let ruleName = ruleNames[ruleIndex];
31187
- if (!ruleName) {
31188
- return decision.toString();
31189
- }
31190
- return `${decision} (${ruleName})`;
31191
- }
31192
- /**
31193
- * Computes the set of conflicting or ambiguous alternatives from a
31194
- * configuration set, if that information was not already provided by the
31195
- * parser.
31196
- *
31197
- * @param reportedAlts The set of conflicting or ambiguous alternatives, as
31198
- * reported by the parser.
31199
- * @param configs The conflicting or ambiguous configuration set.
31200
- * @returns Returns `reportedAlts` if it is not `undefined`, otherwise
31201
- * returns the set of alternatives represented in `configs`.
31202
- */
31203
- getConflictingAlts(reportedAlts, configs) {
31204
- if (reportedAlts != null) {
31205
- return reportedAlts;
31206
- }
31207
- let result = new BitSet_1.BitSet();
31208
- for (let config of configs) {
31209
- result.set(config.alt);
31210
- }
31211
- return result;
31212
- }
31213
- };
31214
- __decorate([
31215
- Decorators_1.Override
31216
- ], DiagnosticErrorListener$1.prototype, "syntaxError", null);
31217
- __decorate([
31218
- Decorators_1.Override,
31219
- __param(0, Decorators_1.NotNull),
31220
- __param(1, Decorators_1.NotNull),
31221
- __param(6, Decorators_1.NotNull)
31222
- ], DiagnosticErrorListener$1.prototype, "reportAmbiguity", null);
31223
- __decorate([
31224
- Decorators_1.Override,
31225
- __param(0, Decorators_1.NotNull),
31226
- __param(1, Decorators_1.NotNull),
31227
- __param(5, Decorators_1.NotNull)
31228
- ], DiagnosticErrorListener$1.prototype, "reportAttemptingFullContext", null);
31229
- __decorate([
31230
- Decorators_1.Override,
31231
- __param(0, Decorators_1.NotNull),
31232
- __param(1, Decorators_1.NotNull),
31233
- __param(5, Decorators_1.NotNull)
31234
- ], DiagnosticErrorListener$1.prototype, "reportContextSensitivity", null);
31235
- __decorate([
31236
- __param(0, Decorators_1.NotNull),
31237
- __param(1, Decorators_1.NotNull)
31238
- ], DiagnosticErrorListener$1.prototype, "getDecisionDescription", null);
31239
- __decorate([
31240
- Decorators_1.NotNull,
31241
- __param(1, Decorators_1.NotNull)
31242
- ], DiagnosticErrorListener$1.prototype, "getConflictingAlts", null);
31243
- DiagnosticErrorListener.DiagnosticErrorListener = DiagnosticErrorListener$1;
31244
-
31245
- return DiagnosticErrorListener;
31246
- }
31247
-
31248
- var LexerInterpreter = {};
31249
-
31250
- var hasRequiredLexerInterpreter;
31251
-
31252
- function requireLexerInterpreter () {
31253
- if (hasRequiredLexerInterpreter) return LexerInterpreter;
31254
- hasRequiredLexerInterpreter = 1;
31255
- /*!
31256
- * Copyright 2016 The ANTLR Project. All rights reserved.
31257
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31258
- */
31259
- var __decorate = (LexerInterpreter && LexerInterpreter.__decorate) || function (decorators, target, key, desc) {
31260
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31261
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31262
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31263
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31264
- };
31265
- var __param = (LexerInterpreter && LexerInterpreter.__param) || function (paramIndex, decorator) {
31266
- return function (target, key) { decorator(target, key, paramIndex); }
31267
- };
31268
- Object.defineProperty(LexerInterpreter, "__esModule", { value: true });
31269
- LexerInterpreter.LexerInterpreter = void 0;
31270
- const Lexer_1 = requireLexer();
31271
- const LexerATNSimulator_1 = requireLexerATNSimulator();
31272
- const Decorators_1 = requireDecorators();
31273
- const Decorators_2 = requireDecorators();
31274
- let LexerInterpreter$1 = class LexerInterpreter extends Lexer_1.Lexer {
31275
- constructor(grammarFileName, vocabulary, ruleNames, channelNames, modeNames, atn, input) {
31276
- super(input);
31277
- if (atn.grammarType !== 0 /* LEXER */) {
31278
- throw new Error("IllegalArgumentException: The ATN must be a lexer ATN.");
31279
- }
31280
- this._grammarFileName = grammarFileName;
31281
- this._atn = atn;
31282
- this._ruleNames = ruleNames.slice(0);
31283
- this._channelNames = channelNames.slice(0);
31284
- this._modeNames = modeNames.slice(0);
31285
- this._vocabulary = vocabulary;
31286
- this._interp = new LexerATNSimulator_1.LexerATNSimulator(atn, this);
31287
- }
31288
- get atn() {
31289
- return this._atn;
31290
- }
31291
- get grammarFileName() {
31292
- return this._grammarFileName;
31293
- }
31294
- get ruleNames() {
31295
- return this._ruleNames;
31296
- }
31297
- get channelNames() {
31298
- return this._channelNames;
31299
- }
31300
- get modeNames() {
31301
- return this._modeNames;
31302
- }
31303
- get vocabulary() {
31304
- return this._vocabulary;
31305
- }
31306
- };
31307
- __decorate([
31308
- Decorators_1.NotNull
31309
- ], LexerInterpreter$1.prototype, "_vocabulary", void 0);
31310
- __decorate([
31311
- Decorators_2.Override
31312
- ], LexerInterpreter$1.prototype, "atn", null);
31313
- __decorate([
31314
- Decorators_2.Override
31315
- ], LexerInterpreter$1.prototype, "grammarFileName", null);
31316
- __decorate([
31317
- Decorators_2.Override
31318
- ], LexerInterpreter$1.prototype, "ruleNames", null);
31319
- __decorate([
31320
- Decorators_2.Override
31321
- ], LexerInterpreter$1.prototype, "channelNames", null);
31322
- __decorate([
31323
- Decorators_2.Override
31324
- ], LexerInterpreter$1.prototype, "modeNames", null);
31325
- __decorate([
31326
- Decorators_2.Override
31327
- ], LexerInterpreter$1.prototype, "vocabulary", null);
31328
- LexerInterpreter$1 = __decorate([
31329
- __param(1, Decorators_1.NotNull)
31330
- ], LexerInterpreter$1);
31331
- LexerInterpreter.LexerInterpreter = LexerInterpreter$1;
31332
-
31333
- return LexerInterpreter;
31334
- }
31335
-
31336
- var ParserErrorListener = {};
31337
-
31338
- var hasRequiredParserErrorListener;
31339
-
31340
- function requireParserErrorListener () {
31341
- if (hasRequiredParserErrorListener) return ParserErrorListener;
31342
- hasRequiredParserErrorListener = 1;
31343
- /*!
31344
- * Copyright 2016 The ANTLR Project. All rights reserved.
31345
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31346
- */
31347
- Object.defineProperty(ParserErrorListener, "__esModule", { value: true });
31348
-
31349
- return ParserErrorListener;
31350
- }
31351
-
31352
- var RuleContextWithAltNum = {};
31353
-
31354
- var hasRequiredRuleContextWithAltNum;
31355
-
31356
- function requireRuleContextWithAltNum () {
31357
- if (hasRequiredRuleContextWithAltNum) return RuleContextWithAltNum;
31358
- hasRequiredRuleContextWithAltNum = 1;
31359
- /*!
31360
- * Copyright 2016 The ANTLR Project. All rights reserved.
31361
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31362
- */
31363
- var __decorate = (RuleContextWithAltNum && RuleContextWithAltNum.__decorate) || function (decorators, target, key, desc) {
31364
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31365
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31366
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31367
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31368
- };
31369
- Object.defineProperty(RuleContextWithAltNum, "__esModule", { value: true });
31370
- RuleContextWithAltNum.RuleContextWithAltNum = void 0;
31371
- // ConvertTo-TS run at 2016-10-04T11:26:57.4741196-07:00
31372
- const ATN_1 = requireATN();
31373
- const Decorators_1 = requireDecorators();
31374
- const ParserRuleContext_1 = requireParserRuleContext();
31375
- /** A handy class for use with
31376
- *
31377
- * options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;}
31378
- *
31379
- * that provides a backing field / impl for the outer alternative number
31380
- * matched for an internal parse tree node.
31381
- *
31382
- * I'm only putting into Java runtime as I'm certain I'm the only one that
31383
- * will really every use this.
31384
- */
31385
- let RuleContextWithAltNum$1 = class RuleContextWithAltNum extends ParserRuleContext_1.ParserRuleContext {
31386
- constructor(parent, invokingStateNumber) {
31387
- if (invokingStateNumber !== undefined) {
31388
- super(parent, invokingStateNumber);
31389
- }
31390
- else {
31391
- super();
31392
- }
31393
- this._altNumber = ATN_1.ATN.INVALID_ALT_NUMBER;
31394
- }
31395
- get altNumber() {
31396
- return this._altNumber;
31397
- }
31398
- // @Override
31399
- set altNumber(altNum) {
31400
- this._altNumber = altNum;
31401
- }
31402
- };
31403
- __decorate([
31404
- Decorators_1.Override
31405
- ], RuleContextWithAltNum$1.prototype, "altNumber", null);
31406
- RuleContextWithAltNum.RuleContextWithAltNum = RuleContextWithAltNum$1;
31407
-
31408
- return RuleContextWithAltNum;
31409
- }
31410
-
31411
- var RuleDependency = {};
31412
-
31413
- var hasRequiredRuleDependency;
31414
-
31415
- function requireRuleDependency () {
31416
- if (hasRequiredRuleDependency) return RuleDependency;
31417
- hasRequiredRuleDependency = 1;
31418
- /*!
31419
- * Copyright 2016 The ANTLR Project. All rights reserved.
31420
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31421
- */
31422
- Object.defineProperty(RuleDependency, "__esModule", { value: true });
31423
- RuleDependency.RuleDependency = void 0;
31424
- /**
31425
- * Declares a dependency upon a grammar rule, along with a set of zero or more dependent rules.
31426
- *
31427
- * Version numbers within a grammar should be assigned on a monotonically increasing basis to allow for accurate
31428
- * tracking of dependent rules.
31429
- *
31430
- * @author Sam Harwell
31431
- */
31432
- function RuleDependency$1(dependency) {
31433
- return (target, propertyKey, propertyDescriptor) => {
31434
- // intentionally empty
31435
- };
31436
- }
31437
- RuleDependency.RuleDependency = RuleDependency$1;
31438
-
31439
- return RuleDependency;
31440
- }
31441
-
31442
- var RuleVersion = {};
31443
-
31444
- var hasRequiredRuleVersion;
31445
-
31446
- function requireRuleVersion () {
31447
- if (hasRequiredRuleVersion) return RuleVersion;
31448
- hasRequiredRuleVersion = 1;
31449
- /*!
31450
- * Copyright 2016 The ANTLR Project. All rights reserved.
31451
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31452
- */
31453
- Object.defineProperty(RuleVersion, "__esModule", { value: true });
31454
- RuleVersion.RuleVersion = void 0;
31455
- /**
31456
- *
31457
- * @author Sam Harwell
31458
- */
31459
- function RuleVersion$1(version) {
31460
- return (target, propertyKey, propertyDescriptor) => {
31461
- // intentionally empty
31462
- };
31463
- }
31464
- RuleVersion.RuleVersion = RuleVersion$1;
31465
-
31466
- return RuleVersion;
31467
- }
31468
-
31469
- var TokenFactory = {};
31470
-
31471
- var hasRequiredTokenFactory;
31472
-
31473
- function requireTokenFactory () {
31474
- if (hasRequiredTokenFactory) return TokenFactory;
31475
- hasRequiredTokenFactory = 1;
31476
- /*!
31477
- * Copyright 2016 The ANTLR Project. All rights reserved.
31478
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31479
- */
31480
- Object.defineProperty(TokenFactory, "__esModule", { value: true });
31481
-
31482
- return TokenFactory;
31483
- }
31484
-
31485
- var TokenSource = {};
31486
-
31487
- var hasRequiredTokenSource;
31488
-
31489
- function requireTokenSource () {
31490
- if (hasRequiredTokenSource) return TokenSource;
31491
- hasRequiredTokenSource = 1;
31492
- /*!
31493
- * Copyright 2016 The ANTLR Project. All rights reserved.
31494
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31495
- */
31496
- Object.defineProperty(TokenSource, "__esModule", { value: true });
31497
-
31498
- return TokenSource;
31499
- }
31500
-
31501
- var TokenStream = {};
31502
-
31503
- var hasRequiredTokenStream;
31504
-
31505
- function requireTokenStream () {
31506
- if (hasRequiredTokenStream) return TokenStream;
31507
- hasRequiredTokenStream = 1;
31508
- /*!
31509
- * Copyright 2016 The ANTLR Project. All rights reserved.
31510
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31511
- */
31512
- Object.defineProperty(TokenStream, "__esModule", { value: true });
31513
-
31514
- return TokenStream;
31515
- }
31516
-
31517
- var TokenStreamRewriter = {};
31518
-
31519
- var hasRequiredTokenStreamRewriter;
31520
-
31521
- function requireTokenStreamRewriter () {
31522
- if (hasRequiredTokenStreamRewriter) return TokenStreamRewriter;
31523
- hasRequiredTokenStreamRewriter = 1;
31524
- /*!
31525
- * Copyright 2016 The ANTLR Project. All rights reserved.
31526
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31527
- */
31528
- var __decorate = (TokenStreamRewriter && TokenStreamRewriter.__decorate) || function (decorators, target, key, desc) {
31529
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31530
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31531
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31532
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31533
- };
31534
- Object.defineProperty(TokenStreamRewriter, "__esModule", { value: true });
31535
- TokenStreamRewriter.RewriteOperation = TokenStreamRewriter.TokenStreamRewriter = void 0;
31536
- // ConvertTo-TS run at 2016-10-04T11:26:58.1768850-07:00
31537
- const Interval_1 = requireInterval();
31538
- const Decorators_1 = requireDecorators();
31539
- const Token_1 = requireToken();
31540
- /**
31541
- * Useful for rewriting out a buffered input token stream after doing some
31542
- * augmentation or other manipulations on it.
31543
- *
31544
- * You can insert stuff, replace, and delete chunks. Note that the operations
31545
- * are done lazily--only if you convert the buffer to a {@link String} with
31546
- * {@link TokenStream#getText()}. This is very efficient because you are not
31547
- * moving data around all the time. As the buffer of tokens is converted to
31548
- * strings, the {@link #getText()} method(s) scan the input token stream and
31549
- * check to see if there is an operation at the current index. If so, the
31550
- * operation is done and then normal {@link String} rendering continues on the
31551
- * buffer. This is like having multiple Turing machine instruction streams
31552
- * (programs) operating on a single input tape. :)
31553
- *
31554
- * This rewriter makes no modifications to the token stream. It does not ask the
31555
- * stream to fill itself up nor does it advance the input cursor. The token
31556
- * stream `TokenStream.index` will return the same value before and
31557
- * after any {@link #getText()} call.
31558
- *
31559
- * The rewriter only works on tokens that you have in the buffer and ignores the
31560
- * current input cursor. If you are buffering tokens on-demand, calling
31561
- * {@link #getText()} halfway through the input will only do rewrites for those
31562
- * tokens in the first half of the file.
31563
- *
31564
- * Since the operations are done lazily at {@link #getText}-time, operations do
31565
- * not screw up the token index values. That is, an insert operation at token
31566
- * index `i` does not change the index values for tokens
31567
- * `i`+1..n-1.
31568
- *
31569
- * Because operations never actually alter the buffer, you may always get the
31570
- * original token stream back without undoing anything. Since the instructions
31571
- * are queued up, you can easily simulate transactions and roll back any changes
31572
- * if there is an error just by removing instructions. For example,
31573
- *
31574
- * ```
31575
- * CharStream input = new ANTLRFileStream("input");
31576
- * TLexer lex = new TLexer(input);
31577
- * CommonTokenStream tokens = new CommonTokenStream(lex);
31578
- * T parser = new T(tokens);
31579
- * TokenStreamRewriter rewriter = new TokenStreamRewriter(tokens);
31580
- * parser.startRule();
31581
- * ```
31582
- *
31583
- * Then in the rules, you can execute (assuming rewriter is visible):
31584
- *
31585
- * ```
31586
- * Token t,u;
31587
- * ...
31588
- * rewriter.insertAfter(t, "text to put after t");}
31589
- * rewriter.insertAfter(u, "text after u");}
31590
- * System.out.println(rewriter.getText());
31591
- * ```
31592
- *
31593
- * You can also have multiple "instruction streams" and get multiple rewrites
31594
- * from a single pass over the input. Just name the instruction streams and use
31595
- * that name again when printing the buffer. This could be useful for generating
31596
- * a C file and also its header file--all from the same buffer:
31597
- *
31598
- * ```
31599
- * rewriter.insertAfter("pass1", t, "text to put after t");}
31600
- * rewriter.insertAfter("pass2", u, "text after u");}
31601
- * System.out.println(rewriter.getText("pass1"));
31602
- * System.out.println(rewriter.getText("pass2"));
31603
- * ```
31604
- *
31605
- * If you don't use named rewrite streams, a "default" stream is used as the
31606
- * first example shows.
31607
- */
31608
- let TokenStreamRewriter$1 = class TokenStreamRewriter {
31609
- constructor(tokens) {
31610
- this.tokens = tokens;
31611
- this.programs = new Map();
31612
- this.programs.set(TokenStreamRewriter.DEFAULT_PROGRAM_NAME, []);
31613
- this.lastRewriteTokenIndexes = new Map();
31614
- }
31615
- getTokenStream() {
31616
- return this.tokens;
31617
- }
31618
- rollback(instructionIndex, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31619
- let is = this.programs.get(programName);
31620
- if (is != null) {
31621
- this.programs.set(programName, is.slice(TokenStreamRewriter.MIN_TOKEN_INDEX, instructionIndex));
31622
- }
31623
- }
31624
- deleteProgram(programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31625
- this.rollback(TokenStreamRewriter.MIN_TOKEN_INDEX, programName);
31626
- }
31627
- insertAfter(tokenOrIndex, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31628
- let index;
31629
- if (typeof tokenOrIndex === "number") {
31630
- index = tokenOrIndex;
31631
- }
31632
- else {
31633
- index = tokenOrIndex.tokenIndex;
31634
- }
31635
- // to insert after, just insert before next index (even if past end)
31636
- let rewrites = this.getProgram(programName);
31637
- let op = new InsertAfterOp(this.tokens, index, rewrites.length, text);
31638
- rewrites.push(op);
31639
- }
31640
- insertBefore(tokenOrIndex, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31641
- let index;
31642
- if (typeof tokenOrIndex === "number") {
31643
- index = tokenOrIndex;
31644
- }
31645
- else {
31646
- index = tokenOrIndex.tokenIndex;
31647
- }
31648
- let rewrites = this.getProgram(programName);
31649
- let op = new InsertBeforeOp(this.tokens, index, rewrites.length, text);
31650
- rewrites.push(op);
31651
- }
31652
- replaceSingle(index, text) {
31653
- if (typeof index === "number") {
31654
- this.replace(index, index, text);
31655
- }
31656
- else {
31657
- this.replace(index, index, text);
31658
- }
31659
- }
31660
- replace(from, to, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31661
- if (typeof from !== "number") {
31662
- from = from.tokenIndex;
31663
- }
31664
- if (typeof to !== "number") {
31665
- to = to.tokenIndex;
31666
- }
31667
- if (from > to || from < 0 || to < 0 || to >= this.tokens.size) {
31668
- throw new RangeError(`replace: range invalid: ${from}..${to}(size=${this.tokens.size})`);
31669
- }
31670
- let rewrites = this.getProgram(programName);
31671
- let op = new ReplaceOp(this.tokens, from, to, rewrites.length, text);
31672
- rewrites.push(op);
31673
- }
31674
- delete(from, to, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31675
- if (to === undefined) {
31676
- to = from;
31677
- }
31678
- if (typeof from === "number") {
31679
- this.replace(from, to, "", programName);
31680
- }
31681
- else {
31682
- this.replace(from, to, "", programName);
31683
- }
31684
- }
31685
- getLastRewriteTokenIndex(programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31686
- let I = this.lastRewriteTokenIndexes.get(programName);
31687
- if (I == null) {
31688
- return -1;
31689
- }
31690
- return I;
31691
- }
31692
- setLastRewriteTokenIndex(programName, i) {
31693
- this.lastRewriteTokenIndexes.set(programName, i);
31694
- }
31695
- getProgram(name) {
31696
- let is = this.programs.get(name);
31697
- if (is == null) {
31698
- is = this.initializeProgram(name);
31699
- }
31700
- return is;
31701
- }
31702
- initializeProgram(name) {
31703
- let is = [];
31704
- this.programs.set(name, is);
31705
- return is;
31706
- }
31707
- getText(intervalOrProgram, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31708
- let interval;
31709
- if (intervalOrProgram instanceof Interval_1.Interval) {
31710
- interval = intervalOrProgram;
31711
- }
31712
- else {
31713
- interval = Interval_1.Interval.of(0, this.tokens.size - 1);
31714
- }
31715
- if (typeof intervalOrProgram === "string") {
31716
- programName = intervalOrProgram;
31717
- }
31718
- let rewrites = this.programs.get(programName);
31719
- let start = interval.a;
31720
- let stop = interval.b;
31721
- // ensure start/end are in range
31722
- if (stop > this.tokens.size - 1) {
31723
- stop = this.tokens.size - 1;
31724
- }
31725
- if (start < 0) {
31726
- start = 0;
31727
- }
31728
- if (rewrites == null || rewrites.length === 0) {
31729
- return this.tokens.getText(interval); // no instructions to execute
31730
- }
31731
- let buf = [];
31732
- // First, optimize instruction stream
31733
- let indexToOp = this.reduceToSingleOperationPerIndex(rewrites);
31734
- // Walk buffer, executing instructions and emitting tokens
31735
- let i = start;
31736
- while (i <= stop && i < this.tokens.size) {
31737
- let op = indexToOp.get(i);
31738
- indexToOp.delete(i); // remove so any left have index size-1
31739
- let t = this.tokens.get(i);
31740
- if (op == null) {
31741
- // no operation at that index, just dump token
31742
- if (t.type !== Token_1.Token.EOF) {
31743
- buf.push(String(t.text));
31744
- }
31745
- i++; // move to next token
31746
- }
31747
- else {
31748
- i = op.execute(buf); // execute operation and skip
31749
- }
31750
- }
31751
- // include stuff after end if it's last index in buffer
31752
- // So, if they did an insertAfter(lastValidIndex, "foo"), include
31753
- // foo if end==lastValidIndex.
31754
- if (stop === this.tokens.size - 1) {
31755
- // Scan any remaining operations after last token
31756
- // should be included (they will be inserts).
31757
- for (let op of indexToOp.values()) {
31758
- if (op.index >= this.tokens.size - 1) {
31759
- buf.push(op.text.toString());
31760
- }
31761
- }
31762
- }
31763
- return buf.join("");
31764
- }
31765
- /** We need to combine operations and report invalid operations (like
31766
- * overlapping replaces that are not completed nested). Inserts to
31767
- * same index need to be combined etc... Here are the cases:
31768
- *
31769
- * I.i.u I.j.v leave alone, nonoverlapping
31770
- * I.i.u I.i.v combine: Iivu
31771
- *
31772
- * R.i-j.u R.x-y.v | i-j in x-y delete first R
31773
- * R.i-j.u R.i-j.v delete first R
31774
- * R.i-j.u R.x-y.v | x-y in i-j ERROR
31775
- * R.i-j.u R.x-y.v | boundaries overlap ERROR
31776
- *
31777
- * Delete special case of replace (text==undefined):
31778
- * D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
31779
- *
31780
- * I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before
31781
- * we're not deleting i)
31782
- * I.i.u R.x-y.v | i not in (x+1)-y leave alone, nonoverlapping
31783
- * R.x-y.v I.i.u | i in x-y ERROR
31784
- * R.x-y.v I.x.u R.x-y.uv (combine, delete I)
31785
- * R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
31786
- *
31787
- * I.i.u = insert u before op @ index i
31788
- * R.x-y.u = replace x-y indexed tokens with u
31789
- *
31790
- * First we need to examine replaces. For any replace op:
31791
- *
31792
- * 1. wipe out any insertions before op within that range.
31793
- * 2. Drop any replace op before that is contained completely within
31794
- * that range.
31795
- * 3. Throw exception upon boundary overlap with any previous replace.
31796
- *
31797
- * Then we can deal with inserts:
31798
- *
31799
- * 1. for any inserts to same index, combine even if not adjacent.
31800
- * 2. for any prior replace with same left boundary, combine this
31801
- * insert with replace and delete this replace.
31802
- * 3. throw exception if index in same range as previous replace
31803
- *
31804
- * Don't actually delete; make op undefined in list. Easier to walk list.
31805
- * Later we can throw as we add to index &rarr; op map.
31806
- *
31807
- * Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
31808
- * inserted stuff would be before the replace range. But, if you
31809
- * add tokens in front of a method body '{' and then delete the method
31810
- * body, I think the stuff before the '{' you added should disappear too.
31811
- *
31812
- * Return a map from token index to operation.
31813
- */
31814
- reduceToSingleOperationPerIndex(rewrites) {
31815
- // console.log(`rewrites=[${Utils.join(rewrites, ", ")}]`);
31816
- // WALK REPLACES
31817
- for (let i = 0; i < rewrites.length; i++) {
31818
- let op = rewrites[i];
31819
- if (op == null) {
31820
- continue;
31821
- }
31822
- if (!(op instanceof ReplaceOp)) {
31823
- continue;
31824
- }
31825
- let rop = op;
31826
- // Wipe prior inserts within range
31827
- let inserts = this.getKindOfOps(rewrites, InsertBeforeOp, i);
31828
- for (let iop of inserts) {
31829
- if (iop.index === rop.index) {
31830
- // E.g., insert before 2, delete 2..2; update replace
31831
- // text to include insert before, kill insert
31832
- rewrites[iop.instructionIndex] = undefined;
31833
- rop.text = iop.text.toString() + (rop.text != null ? rop.text.toString() : "");
31834
- }
31835
- else if (iop.index > rop.index && iop.index <= rop.lastIndex) {
31836
- // delete insert as it's a no-op.
31837
- rewrites[iop.instructionIndex] = undefined;
31838
- }
31839
- }
31840
- // Drop any prior replaces contained within
31841
- let prevReplaces = this.getKindOfOps(rewrites, ReplaceOp, i);
31842
- for (let prevRop of prevReplaces) {
31843
- if (prevRop.index >= rop.index && prevRop.lastIndex <= rop.lastIndex) {
31844
- // delete replace as it's a no-op.
31845
- rewrites[prevRop.instructionIndex] = undefined;
31846
- continue;
31847
- }
31848
- // throw exception unless disjoint or identical
31849
- let disjoint = prevRop.lastIndex < rop.index || prevRop.index > rop.lastIndex;
31850
- // Delete special case of replace (text==null):
31851
- // D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
31852
- if (prevRop.text == null && rop.text == null && !disjoint) {
31853
- // console.log(`overlapping deletes: ${prevRop}, ${rop}`);
31854
- rewrites[prevRop.instructionIndex] = undefined; // kill first delete
31855
- rop.index = Math.min(prevRop.index, rop.index);
31856
- rop.lastIndex = Math.max(prevRop.lastIndex, rop.lastIndex);
31857
- // console.log(`new rop ${rop}`);
31858
- }
31859
- else if (!disjoint) {
31860
- throw new Error(`replace op boundaries of ${rop} overlap with previous ${prevRop}`);
31861
- }
31862
- }
31863
- }
31864
- // WALK INSERTS
31865
- for (let i = 0; i < rewrites.length; i++) {
31866
- let op = rewrites[i];
31867
- if (op == null) {
31868
- continue;
31869
- }
31870
- if (!(op instanceof InsertBeforeOp)) {
31871
- continue;
31872
- }
31873
- let iop = op;
31874
- // combine current insert with prior if any at same index
31875
- let prevInserts = this.getKindOfOps(rewrites, InsertBeforeOp, i);
31876
- for (let prevIop of prevInserts) {
31877
- if (prevIop.index === iop.index) {
31878
- if (prevIop instanceof InsertAfterOp) {
31879
- iop.text = this.catOpText(prevIop.text, iop.text);
31880
- rewrites[prevIop.instructionIndex] = undefined;
31881
- }
31882
- else if (prevIop instanceof InsertBeforeOp) { // combine objects
31883
- // convert to strings...we're in process of toString'ing
31884
- // whole token buffer so no lazy eval issue with any templates
31885
- iop.text = this.catOpText(iop.text, prevIop.text);
31886
- // delete redundant prior insert
31887
- rewrites[prevIop.instructionIndex] = undefined;
31888
- }
31889
- }
31890
- }
31891
- // look for replaces where iop.index is in range; error
31892
- let prevReplaces = this.getKindOfOps(rewrites, ReplaceOp, i);
31893
- for (let rop of prevReplaces) {
31894
- if (iop.index === rop.index) {
31895
- rop.text = this.catOpText(iop.text, rop.text);
31896
- rewrites[i] = undefined; // delete current insert
31897
- continue;
31898
- }
31899
- if (iop.index >= rop.index && iop.index <= rop.lastIndex) {
31900
- throw new Error(`insert op ${iop} within boundaries of previous ${rop}`);
31901
- }
31902
- }
31903
- }
31904
- // console.log(`rewrites after=[${Utils.join(rewrites, ", ")}]`);
31905
- let m = new Map();
31906
- for (let op of rewrites) {
31907
- if (op == null) {
31908
- // ignore deleted ops
31909
- continue;
31910
- }
31911
- if (m.get(op.index) != null) {
31912
- throw new Error("should only be one op per index");
31913
- }
31914
- m.set(op.index, op);
31915
- }
31916
- // console.log(`index to op: ${m}`);
31917
- return m;
31918
- }
31919
- catOpText(a, b) {
31920
- let x = "";
31921
- let y = "";
31922
- if (a != null) {
31923
- x = a.toString();
31924
- }
31925
- if (b != null) {
31926
- y = b.toString();
31927
- }
31928
- return x + y;
31929
- }
31930
- /** Get all operations before an index of a particular kind */
31931
- getKindOfOps(rewrites, kind, before) {
31932
- let ops = [];
31933
- for (let i = 0; i < before && i < rewrites.length; i++) {
31934
- let op = rewrites[i];
31935
- if (op == null) {
31936
- // ignore deleted
31937
- continue;
31938
- }
31939
- if (op instanceof kind) {
31940
- ops.push(op);
31941
- }
31942
- }
31943
- return ops;
31944
- }
31945
- };
31946
- TokenStreamRewriter.TokenStreamRewriter = TokenStreamRewriter$1;
31947
- TokenStreamRewriter$1.DEFAULT_PROGRAM_NAME = "default";
31948
- TokenStreamRewriter$1.PROGRAM_INIT_SIZE = 100;
31949
- TokenStreamRewriter$1.MIN_TOKEN_INDEX = 0;
31950
- // Define the rewrite operation hierarchy
31951
- class RewriteOperation {
31952
- constructor(tokens, index, instructionIndex, text) {
31953
- this.tokens = tokens;
31954
- this.instructionIndex = instructionIndex;
31955
- this.index = index;
31956
- this.text = text === undefined ? "" : text;
31957
- }
31958
- /** Execute the rewrite operation by possibly adding to the buffer.
31959
- * Return the index of the next token to operate on.
31960
- */
31961
- execute(buf) {
31962
- return this.index;
31963
- }
31964
- toString() {
31965
- let opName = this.constructor.name;
31966
- let $index = opName.indexOf("$");
31967
- opName = opName.substring($index + 1, opName.length);
31968
- return "<" + opName + "@" + this.tokens.get(this.index) +
31969
- ":\"" + this.text + "\">";
31970
- }
31971
- }
31972
- __decorate([
31973
- Decorators_1.Override
31974
- ], RewriteOperation.prototype, "toString", null);
31975
- TokenStreamRewriter.RewriteOperation = RewriteOperation;
31976
- class InsertBeforeOp extends RewriteOperation {
31977
- constructor(tokens, index, instructionIndex, text) {
31978
- super(tokens, index, instructionIndex, text);
31979
- }
31980
- execute(buf) {
31981
- buf.push(this.text.toString());
31982
- if (this.tokens.get(this.index).type !== Token_1.Token.EOF) {
31983
- buf.push(String(this.tokens.get(this.index).text));
31984
- }
31985
- return this.index + 1;
31986
- }
31987
- }
31988
- __decorate([
31989
- Decorators_1.Override
31990
- ], InsertBeforeOp.prototype, "execute", null);
31991
- /** Distinguish between insert after/before to do the "insert afters"
31992
- * first and then the "insert befores" at same index. Implementation
31993
- * of "insert after" is "insert before index+1".
31994
- */
31995
- class InsertAfterOp extends InsertBeforeOp {
31996
- constructor(tokens, index, instructionIndex, text) {
31997
- super(tokens, index + 1, instructionIndex, text); // insert after is insert before index+1
31998
- }
31999
- }
32000
- /** I'm going to try replacing range from x..y with (y-x)+1 ReplaceOp
32001
- * instructions.
32002
- */
32003
- class ReplaceOp extends RewriteOperation {
32004
- constructor(tokens, from, to, instructionIndex, text) {
32005
- super(tokens, from, instructionIndex, text);
32006
- this.lastIndex = to;
32007
- }
32008
- execute(buf) {
32009
- if (this.text != null) {
32010
- buf.push(this.text.toString());
32011
- }
32012
- return this.lastIndex + 1;
32013
- }
32014
- toString() {
32015
- if (this.text == null) {
32016
- return "<DeleteOp@" + this.tokens.get(this.index) +
32017
- ".." + this.tokens.get(this.lastIndex) + ">";
32018
- }
32019
- return "<ReplaceOp@" + this.tokens.get(this.index) +
32020
- ".." + this.tokens.get(this.lastIndex) + ":\"" + this.text + "\">";
32021
- }
32022
- }
32023
- __decorate([
32024
- Decorators_1.Override
32025
- ], ReplaceOp.prototype, "execute", null);
32026
- __decorate([
32027
- Decorators_1.Override
32028
- ], ReplaceOp.prototype, "toString", null);
32029
-
32030
- return TokenStreamRewriter;
32031
- }
32032
-
32033
- var Vocabulary = {};
32034
-
32035
- var hasRequiredVocabulary;
32036
-
32037
- function requireVocabulary () {
32038
- if (hasRequiredVocabulary) return Vocabulary;
32039
- hasRequiredVocabulary = 1;
32040
- /*!
32041
- * Copyright 2016 The ANTLR Project. All rights reserved.
32042
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
32043
- */
32044
- Object.defineProperty(Vocabulary, "__esModule", { value: true });
32045
-
32046
- return Vocabulary;
32047
- }
32048
-
32049
- var WritableToken = {};
32050
-
32051
- var hasRequiredWritableToken;
32052
-
32053
- function requireWritableToken () {
32054
- if (hasRequiredWritableToken) return WritableToken;
32055
- hasRequiredWritableToken = 1;
32056
- /*!
32057
- * Copyright 2016 The ANTLR Project. All rights reserved.
32058
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
32059
- */
32060
- Object.defineProperty(WritableToken, "__esModule", { value: true });
32061
-
32062
- return WritableToken;
32063
- }
32064
-
32065
- var hasRequiredAntlr4ts;
32066
-
32067
- function requireAntlr4ts () {
32068
- if (hasRequiredAntlr4ts) return antlr4ts;
32069
- hasRequiredAntlr4ts = 1;
32070
- (function (exports) {
32071
- /*!
32072
- * Copyright 2016 The ANTLR Project. All rights reserved.
32073
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
32074
- */
32075
- var __createBinding = (antlr4ts && antlr4ts.__createBinding) || (Object.create ? (function(o, m, k, k2) {
32076
- if (k2 === undefined) k2 = k;
32077
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
32078
- }) : (function(o, m, k, k2) {
32079
- if (k2 === undefined) k2 = k;
32080
- o[k2] = m[k];
32081
- }));
32082
- var __exportStar = (antlr4ts && antlr4ts.__exportStar) || function(m, exports) {
32083
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32084
- };
32085
- Object.defineProperty(exports, "__esModule", { value: true });
32086
- __exportStar(requireANTLRErrorListener(), exports);
32087
- __exportStar(requireANTLRErrorStrategy(), exports);
32088
- // export * from "./ANTLRFileStream";
32089
- __exportStar(requireANTLRInputStream(), exports);
32090
- __exportStar(requireBailErrorStrategy(), exports);
32091
- __exportStar(requireBufferedTokenStream(), exports);
32092
- __exportStar(requireCharStream(), exports);
32093
- __exportStar(requireCharStreams(), exports);
32094
- __exportStar(requireCodePointBuffer(), exports);
32095
- __exportStar(requireCodePointCharStream(), exports);
32096
- __exportStar(requireCommonToken(), exports);
32097
- __exportStar(requireCommonTokenFactory(), exports);
32098
- __exportStar(requireCommonTokenStream(), exports);
32099
- __exportStar(requireConsoleErrorListener(), exports);
32100
- __exportStar(requireDefaultErrorStrategy(), exports);
32101
- __exportStar(requireDependents(), exports);
32102
- __exportStar(requireDiagnosticErrorListener(), exports);
32103
- __exportStar(requireFailedPredicateException(), exports);
32104
- __exportStar(requireInputMismatchException(), exports);
32105
- __exportStar(requireInterpreterRuleContext(), exports);
32106
- __exportStar(requireIntStream(), exports);
32107
- __exportStar(requireLexer(), exports);
32108
- __exportStar(requireLexerInterpreter(), exports);
32109
- __exportStar(requireLexerNoViableAltException(), exports);
32110
- __exportStar(requireListTokenSource(), exports);
32111
- __exportStar(requireNoViableAltException(), exports);
32112
- __exportStar(requireParser(), exports);
32113
- __exportStar(requireParserErrorListener(), exports);
32114
- __exportStar(requireParserInterpreter(), exports);
32115
- __exportStar(requireParserRuleContext(), exports);
32116
- __exportStar(requireProxyErrorListener(), exports);
32117
- __exportStar(requireProxyParserErrorListener(), exports);
32118
- __exportStar(requireRecognitionException(), exports);
32119
- __exportStar(requireRecognizer(), exports);
32120
- __exportStar(requireRuleContext(), exports);
32121
- __exportStar(requireRuleContextWithAltNum(), exports);
32122
- __exportStar(requireRuleDependency(), exports);
32123
- __exportStar(requireRuleVersion(), exports);
32124
- __exportStar(requireToken(), exports);
32125
- __exportStar(requireTokenFactory(), exports);
32126
- __exportStar(requireTokenSource(), exports);
32127
- __exportStar(requireTokenStream(), exports);
32128
- __exportStar(requireTokenStreamRewriter(), exports);
32129
- // export * from "./UnbufferedCharStream";
32130
- // export * from "./UnbufferedTokenStream";
32131
- __exportStar(requireVocabulary(), exports);
32132
- __exportStar(requireVocabularyImpl(), exports);
32133
- __exportStar(requireWritableToken(), exports);
32134
-
32135
- } (antlr4ts));
32136
- return antlr4ts;
32137
- }
32138
-
32139
- var antlr4tsExports = requireAntlr4ts();
32140
-
32141
30797
  var ATNExports = requireATN();
32142
30798
 
32143
30799
  var FailedPredicateExceptionExports = requireFailedPredicateException();
@@ -40852,9 +39508,9 @@ class IdentifierContext extends ParserRuleContextExports.ParserRuleContext {
40852
39508
  }
40853
39509
 
40854
39510
  function getParser(inputText) {
40855
- const inputStream = antlr4tsExports.CharStreams.fromString(inputText);
39511
+ const inputStream = CharStreams$1.fromString(inputText);
40856
39512
  const lexer = new BattleScriptLexer(inputStream);
40857
- const tokenStream = new antlr4tsExports.CommonTokenStream(lexer);
39513
+ const tokenStream = new CommonTokenStream$1(lexer);
40858
39514
  return new BattleScriptParser(tokenStream);
40859
39515
  }
40860
39516
  // Function to Parse and Convert BattleScript to JSON
@@ -41097,4 +39753,4 @@ function EnumNodePropFromString(prop) {
41097
39753
  }
41098
39754
 
41099
39755
  export { AfterDeclarationNodeLayout, AfterExpressionNodeLayout, ArrayExpressionNodeLayout, AssignmentExpressionNodeLayout, AssignmentPatternNodeLayout, BattleScriptFromAST, BattleScriptMiniAstInterpreter, BattleScriptToAST, BattleScriptToMiniAST, BinaryExpressionNodeLayout, BlockStatementNodeLayout, BreakStatementNodeLayout, CallExpressionNodeLayout, CancelStatementNodeLayout, CatchStatementNodeLayout, CommentNodeLayout, ConstantDeclarationNodeLayout, ConstantDeclaratorNodeLayout, ContinueStatementNodeLayout, CustomTypeNodeLayout, DataTypeNodeLayout, DefineStatementNodeLayout, EnumByteCodeFormat, EnumByteCodeFormatFromString, EnumByteCodeFormatToString, EnumDeclarationNodeLayout, EnumFunctionType, EnumFunctionTypeFromString, EnumFunctionTypeToString, EnumLiteralType, EnumLiteralTypeFromString, EnumLiteralTypeToString, EnumNodeBinaryType, EnumNodeBinaryTypeFromString, EnumNodeBinaryTypeToString, EnumNodeKind, EnumNodeKindFromString, EnumNodeKindToString, EnumNodeLayoutEntry, EnumNodeLayoutEntryFromString, EnumNodeLayoutEntryToString, EnumNodeProp, EnumNodePropFromString, EnumNodePropToString, EnumOpCode, EnumOpCodeFromString, EnumOpCodeToString, EnumOperator, EnumOperatorFromString, EnumOperatorToString, EvaluateCaseNodeLayout, EvaluateFallbackNodeLayout, EvaluateStatementNodeLayout, EventDeclarationNodeLayout, EveryDeclarationNodeLayout, EveryExpressionNodeLayout, ExpressionStatementNodeLayout, ForStatementNodeLayout, FunctionDeclarationNodeLayout, FunctionDefinitionNodeLayout, IdentifierNodeLayout, IfStatementNodeLayout, ImportDeclarationNodeLayout, InterfaceNodeLayout, InterfacePropertyDeclarationNodeLayout, LiteralBooleanNodeLayout, LiteralDoubleNodeLayout, LiteralFloatNodeLayout, LiteralIntNodeLayout, LiteralNullNodeLayout, LiteralStringNodeLayout, LiteralUndefinedNodeLayout, MemberExpressionNodeLayout, MiniAstToFullAst, ObjectExpressionNodeLayout, ObjectPropertyNodeLayout, OptimisedAssignmentExpressionNodeLayout, OptimisedBinaryExpressionNodeLayout, OptimisedMemberExpressionNodeLayout, OptimisedUpdateExpressionNodeLayout, ProgramDeclarationNodeLayout, ProgramPropertyDeclarationNodeLayout, ProtocolDeclarationNodeLayout, ProtocolTypeNodeLayout, RequireStatementNodeLayout, RestElementNodeLayout, ReturnStatementNodeLayout, RootNodeLayout, StateDeclarationNodeLayout, StepDeclarationNodeLayout, UnaryExpressionNodeLayout, UpdateExpressionNodeLayout, VariableDeclarationNodeLayout, VariableDeclaratorNodeLayout, WildcardNodeLayout, afterDeclarationFromAstNode, afterDeclarationToAstNode, afterExpressionFromAstNode, afterExpressionToAstNode, arrayExpressionFromAstNode, arrayExpressionInternalToAstNode, assignmentExpressionFromAstNode, assignmentExpressionToAstNode, assignmentPatternToAstNode, binaryExpressionFromAstNode, binaryExpressionToAstNode, blockStatementFromAstNode, blockStatementToAstNode, booleanLiteralToAstNode, breakStatementFromAstNode, breakStatementToAstNode, callExpressionFromAstNode, callExpressionToAstNode, cancelStatementFromAstNode, cancelStatementToAstNode, catchAsStatementToAstNode, catchStatementFromAstNode, catchStatementToAstNode, commentFromAstNode, commentToAstNode, computedMemberExpressionToAstNode, constantDeclarationFromAstNode, constantDeclaratorFromAstNode, constantDeclaratorToAstNode, continueStatementFromAstNode, continueStatementToAstNode, customTypeFromAstNode, customTypeToAstNode, dataTypeFromAstNode, dataTypeToAstNode, defineStatementFromAstNode, defineStatementToAstNode, enumDeclarationFromAstNode, enumDeclarationToAstNode, evaluateCaseFromAstNode, evaluateCaseToAstNode, evaluateFallbackFromAstNode, evaluateFallbackToAstNode, evaluateStatementFromAstNode, evaluateStatementToAstNode, eventDeclarationFromAstNode, eventDeclarationToAstNode, everyDeclarationFromAstNode, everyDeclarationToAstNode, everyExpressionFromAstNode, everyExpressionToAstNode, expressionStatementFromAstNode, expressionStatementToAstNode, forStatementFromAstNode, forStatementToAstNode, fromBinaryToMiniAst, fromFullAstToSourceCode, fromMiniAstToAst, fromMiniAstToBinary, fromMiniAstToSourceCode, fromSourceCodeToBinary, fromSourceCodeToFullAst, fromSourceCodeToMiniAst, functionDeclarationFromAstNode, functionDeclarationToAstNode, functionDefinitionFromAstNode, functionDefinitionToAstNode, functionNameIdentifierToAstNode, functionParameterFromAstNode, getParser, identifierFromAstNode, identifierToAstNode, ifStatementFromAstNode, ifStatementToAstNode, importDeclarationFromAstNode, importExternalToAstNode, importNativeToAstNode, interfaceDeclarationFromAstNode, interfaceDeclarationToAstNode, interfacePropertyDeclarationFromAstNode, interfacePropertyToAstNode, literalBooleanFromAstNode, literalDoubleFromAstNode, literalFloatFromAstNode, literalIntFromAstNode, literalNullFromAstNode, literalStringFromAstNode, literalUndefinedFromAstNode, memberExpressionFromAstNode, miniAstFromBinaryBuffer, miniAstLayout, miniAstToBinary, namespacedMemberExpressionToAstNode, nonComputedMemberExpressionToAstNode, nullLiteralToAstNode, numberLiteralToAstNode, objectExpressionFromAstNode, objectExpressionInternalToAstNode, objectPropertyFromAstNode, objectPropertyToAstNode, optimisedAssignmentExpressionFromAstNode, optimisedAssignmentExpressionToAstNode, optimisedBinaryExpressionFromAstNode, optimisedBinaryExpressionToAstNode, optimisedMemberExpressionFromAstNode, optimisedUpdateExpressionFromAstNode, optimisedUpdateExpressionToAstNode, programDeclarationFromAstNode, programDeclarationToAstNode, programPropertyDeclarationFromAstNode, programPropertyToAstNode, protocolDeclarationFromAstNode, protocolDeclarationToAstNode, protocolTypeFromAstNode, protocolTypeToAstNode, requireStatementFromAstNode, requireStatementToAstNode, restElementFromAstNode, restElementToAstNode, returnFromAstNode, returnStatementToAstNode, rootFromAstNode, rootToAstNode, stateDeclarationFromAstNode, stateDeclarationToAstNode, stepDeclarationFromAstNode, stepDeclarationToAstNode, stringLiteralToAstNode, unaryExpressionFromAstNode, unaryExpressionToAstNode, undefinedLiteralToAstNode, updateExpressionFromAstNode, updateExpressionToAstNode, variableDeclarationFromAstNode, variableDeclarationToAstNode, variableDeclaratorFromAstNode, variableDeclaratorToAstNode, wildcardFromAstNode, wildcardToAstNode };
41100
- //# sourceMappingURL=index.js.map
39756
+ //# sourceMappingURL=index.mjs.map