@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.
package/bin/index.js CHANGED
@@ -3,6 +3,7 @@ import { writeFile, readFile } from 'fs/promises';
3
3
  import { join, dirname, basename, extname } from 'path';
4
4
  import require$$0 from 'assert';
5
5
  import require$$0$1 from 'util';
6
+ import { CharStreams as CharStreams$1, CommonTokenStream as CommonTokenStream$1 } from 'antlr4ts';
6
7
  import { readFileSync } from 'fs';
7
8
  import 'node:fs';
8
9
 
@@ -30393,7 +30394,7 @@ function miniAstFromBinaryBuffer(data) {
30393
30394
  };
30394
30395
  }
30395
30396
 
30396
- var version = "3.2.1";
30397
+ var version = "3.2.2";
30397
30398
  var binaryVersion = 7;
30398
30399
 
30399
30400
  function miniAstToBinary$1(json, options = {}) {
@@ -30554,1351 +30555,6 @@ var EnumOpCode;
30554
30555
  EnumOpCode[EnumOpCode["OPCODE_MOD"] = 22] = "OPCODE_MOD";
30555
30556
  })(EnumOpCode || (EnumOpCode = {}));
30556
30557
 
30557
- var antlr4ts = {};
30558
-
30559
- var ANTLRErrorListener = {};
30560
-
30561
- var hasRequiredANTLRErrorListener;
30562
-
30563
- function requireANTLRErrorListener () {
30564
- if (hasRequiredANTLRErrorListener) return ANTLRErrorListener;
30565
- hasRequiredANTLRErrorListener = 1;
30566
- /*!
30567
- * Copyright 2016 The ANTLR Project. All rights reserved.
30568
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30569
- */
30570
- Object.defineProperty(ANTLRErrorListener, "__esModule", { value: true });
30571
-
30572
- return ANTLRErrorListener;
30573
- }
30574
-
30575
- var ANTLRErrorStrategy = {};
30576
-
30577
- var hasRequiredANTLRErrorStrategy;
30578
-
30579
- function requireANTLRErrorStrategy () {
30580
- if (hasRequiredANTLRErrorStrategy) return ANTLRErrorStrategy;
30581
- hasRequiredANTLRErrorStrategy = 1;
30582
- /*!
30583
- * Copyright 2016 The ANTLR Project. All rights reserved.
30584
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30585
- */
30586
- Object.defineProperty(ANTLRErrorStrategy, "__esModule", { value: true });
30587
-
30588
- return ANTLRErrorStrategy;
30589
- }
30590
-
30591
- var ANTLRInputStream = {};
30592
-
30593
- var hasRequiredANTLRInputStream;
30594
-
30595
- function requireANTLRInputStream () {
30596
- if (hasRequiredANTLRInputStream) return ANTLRInputStream;
30597
- hasRequiredANTLRInputStream = 1;
30598
- /*!
30599
- * Copyright 2016 The ANTLR Project. All rights reserved.
30600
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30601
- */
30602
- // ConvertTo-TS run at 2016-10-04T11:26:49.0828748-07:00
30603
- var __decorate = (ANTLRInputStream && ANTLRInputStream.__decorate) || function (decorators, target, key, desc) {
30604
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30605
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30606
- 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;
30607
- return c > 3 && r && Object.defineProperty(target, key, r), r;
30608
- };
30609
- Object.defineProperty(ANTLRInputStream, "__esModule", { value: true });
30610
- ANTLRInputStream.ANTLRInputStream = void 0;
30611
- const assert = require$$0;
30612
- const Decorators_1 = requireDecorators();
30613
- const IntStream_1 = requireIntStream();
30614
- /**
30615
- * Vacuum all input from a {@link Reader}/{@link InputStream} and then treat it
30616
- * like a `char[]` buffer. Can also pass in a {@link String} or
30617
- * `char[]` to use.
30618
- *
30619
- * If you need encoding, pass in stream/reader with correct encoding.
30620
- *
30621
- * @deprecated as of 4.7, please use `CharStreams` interface.
30622
- */
30623
- let ANTLRInputStream$1 = class ANTLRInputStream {
30624
- /** Copy data in string to a local char array */
30625
- constructor(input) {
30626
- /** 0..n-1 index into string of next char */
30627
- this.p = 0;
30628
- this.data = input;
30629
- this.n = input.length;
30630
- }
30631
- /** Reset the stream so that it's in the same state it was
30632
- * when the object was created *except* the data array is not
30633
- * touched.
30634
- */
30635
- reset() {
30636
- this.p = 0;
30637
- }
30638
- consume() {
30639
- if (this.p >= this.n) {
30640
- assert(this.LA(1) === IntStream_1.IntStream.EOF);
30641
- throw new Error("cannot consume EOF");
30642
- }
30643
- //System.out.println("prev p="+p+", c="+(char)data[p]);
30644
- if (this.p < this.n) {
30645
- this.p++;
30646
- //System.out.println("p moves to "+p+" (c='"+(char)data[p]+"')");
30647
- }
30648
- }
30649
- LA(i) {
30650
- if (i === 0) {
30651
- return 0; // undefined
30652
- }
30653
- if (i < 0) {
30654
- i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
30655
- if ((this.p + i - 1) < 0) {
30656
- return IntStream_1.IntStream.EOF; // invalid; no char before first char
30657
- }
30658
- }
30659
- if ((this.p + i - 1) >= this.n) {
30660
- //System.out.println("char LA("+i+")=EOF; p="+p);
30661
- return IntStream_1.IntStream.EOF;
30662
- }
30663
- //System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p);
30664
- //System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length);
30665
- return this.data.charCodeAt(this.p + i - 1);
30666
- }
30667
- LT(i) {
30668
- return this.LA(i);
30669
- }
30670
- /** Return the current input symbol index 0..n where n indicates the
30671
- * last symbol has been read. The index is the index of char to
30672
- * be returned from LA(1).
30673
- */
30674
- get index() {
30675
- return this.p;
30676
- }
30677
- get size() {
30678
- return this.n;
30679
- }
30680
- /** mark/release do nothing; we have entire buffer */
30681
- mark() {
30682
- return -1;
30683
- }
30684
- release(marker) {
30685
- // No default implementation since this stream buffers the entire input
30686
- }
30687
- /** consume() ahead until p==index; can't just set p=index as we must
30688
- * update line and charPositionInLine. If we seek backwards, just set p
30689
- */
30690
- seek(index) {
30691
- if (index <= this.p) {
30692
- this.p = index; // just jump; don't update stream state (line, ...)
30693
- return;
30694
- }
30695
- // seek forward, consume until p hits index or n (whichever comes first)
30696
- index = Math.min(index, this.n);
30697
- while (this.p < index) {
30698
- this.consume();
30699
- }
30700
- }
30701
- getText(interval) {
30702
- let start = interval.a;
30703
- let stop = interval.b;
30704
- if (stop >= this.n) {
30705
- stop = this.n - 1;
30706
- }
30707
- let count = stop - start + 1;
30708
- if (start >= this.n) {
30709
- return "";
30710
- }
30711
- // System.err.println("data: "+Arrays.toString(data)+", n="+n+
30712
- // ", start="+start+
30713
- // ", stop="+stop);
30714
- return this.data.substr(start, count);
30715
- }
30716
- get sourceName() {
30717
- if (!this.name) {
30718
- return IntStream_1.IntStream.UNKNOWN_SOURCE_NAME;
30719
- }
30720
- return this.name;
30721
- }
30722
- toString() { return this.data; }
30723
- };
30724
- __decorate([
30725
- Decorators_1.Override
30726
- ], ANTLRInputStream$1.prototype, "consume", null);
30727
- __decorate([
30728
- Decorators_1.Override
30729
- ], ANTLRInputStream$1.prototype, "LA", null);
30730
- __decorate([
30731
- Decorators_1.Override
30732
- ], ANTLRInputStream$1.prototype, "index", null);
30733
- __decorate([
30734
- Decorators_1.Override
30735
- ], ANTLRInputStream$1.prototype, "size", null);
30736
- __decorate([
30737
- Decorators_1.Override
30738
- ], ANTLRInputStream$1.prototype, "mark", null);
30739
- __decorate([
30740
- Decorators_1.Override
30741
- ], ANTLRInputStream$1.prototype, "release", null);
30742
- __decorate([
30743
- Decorators_1.Override
30744
- ], ANTLRInputStream$1.prototype, "seek", null);
30745
- __decorate([
30746
- Decorators_1.Override
30747
- ], ANTLRInputStream$1.prototype, "getText", null);
30748
- __decorate([
30749
- Decorators_1.Override
30750
- ], ANTLRInputStream$1.prototype, "sourceName", null);
30751
- __decorate([
30752
- Decorators_1.Override
30753
- ], ANTLRInputStream$1.prototype, "toString", null);
30754
- ANTLRInputStream.ANTLRInputStream = ANTLRInputStream$1;
30755
-
30756
- return ANTLRInputStream;
30757
- }
30758
-
30759
- var CharStream = {};
30760
-
30761
- var hasRequiredCharStream;
30762
-
30763
- function requireCharStream () {
30764
- if (hasRequiredCharStream) return CharStream;
30765
- hasRequiredCharStream = 1;
30766
- /*!
30767
- * Copyright 2016 The ANTLR Project. All rights reserved.
30768
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30769
- */
30770
- Object.defineProperty(CharStream, "__esModule", { value: true });
30771
-
30772
- return CharStream;
30773
- }
30774
-
30775
- var Dependents = {};
30776
-
30777
- var hasRequiredDependents;
30778
-
30779
- function requireDependents () {
30780
- if (hasRequiredDependents) return Dependents;
30781
- hasRequiredDependents = 1;
30782
- (function (exports) {
30783
- /*!
30784
- * Copyright 2016 The ANTLR Project. All rights reserved.
30785
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30786
- */
30787
- Object.defineProperty(exports, "__esModule", { value: true });
30788
- exports.Dependents = void 0;
30789
- (function (Dependents) {
30790
- /**
30791
- * The element is dependent upon the specified rule.
30792
- */
30793
- Dependents[Dependents["SELF"] = 0] = "SELF";
30794
- /**
30795
- * The element is dependent upon the set of the specified rule's parents
30796
- * (rules which directly reference it).
30797
- */
30798
- Dependents[Dependents["PARENTS"] = 1] = "PARENTS";
30799
- /**
30800
- * The element is dependent upon the set of the specified rule's children
30801
- * (rules which it directly references).
30802
- */
30803
- Dependents[Dependents["CHILDREN"] = 2] = "CHILDREN";
30804
- /**
30805
- * The element is dependent upon the set of the specified rule's ancestors
30806
- * (the transitive closure of `PARENTS` rules).
30807
- */
30808
- Dependents[Dependents["ANCESTORS"] = 3] = "ANCESTORS";
30809
- /**
30810
- * The element is dependent upon the set of the specified rule's descendants
30811
- * (the transitive closure of `CHILDREN` rules).
30812
- */
30813
- Dependents[Dependents["DESCENDANTS"] = 4] = "DESCENDANTS";
30814
- /**
30815
- * The element is dependent upon the set of the specified rule's siblings
30816
- * (the union of `CHILDREN` of its `PARENTS`).
30817
- */
30818
- Dependents[Dependents["SIBLINGS"] = 5] = "SIBLINGS";
30819
- /**
30820
- * The element is dependent upon the set of the specified rule's preceeding
30821
- * siblings (the union of `CHILDREN` of its `PARENTS` which
30822
- * appear before a reference to the rule).
30823
- */
30824
- Dependents[Dependents["PRECEEDING_SIBLINGS"] = 6] = "PRECEEDING_SIBLINGS";
30825
- /**
30826
- * The element is dependent upon the set of the specified rule's following
30827
- * siblings (the union of `CHILDREN` of its `PARENTS` which
30828
- * appear after a reference to the rule).
30829
- */
30830
- Dependents[Dependents["FOLLOWING_SIBLINGS"] = 7] = "FOLLOWING_SIBLINGS";
30831
- /**
30832
- * The element is dependent upon the set of the specified rule's preceeding
30833
- * elements (rules which might end before the start of the specified rule
30834
- * while parsing). This is calculated by taking the
30835
- * `PRECEEDING_SIBLINGS` of the rule and each of its
30836
- * `ANCESTORS`, along with the `DESCENDANTS` of those
30837
- * elements.
30838
- */
30839
- Dependents[Dependents["PRECEEDING"] = 8] = "PRECEEDING";
30840
- /**
30841
- * The element is dependent upon the set of the specified rule's following
30842
- * elements (rules which might start after the end of the specified rule
30843
- * while parsing). This is calculated by taking the
30844
- * `FOLLOWING_SIBLINGS` of the rule and each of its
30845
- * `ANCESTORS`, along with the `DESCENDANTS` of those
30846
- * elements.
30847
- */
30848
- Dependents[Dependents["FOLLOWING"] = 9] = "FOLLOWING";
30849
- })(exports.Dependents || (exports.Dependents = {}));
30850
-
30851
- } (Dependents));
30852
- return Dependents;
30853
- }
30854
-
30855
- var DiagnosticErrorListener = {};
30856
-
30857
- var hasRequiredDiagnosticErrorListener;
30858
-
30859
- function requireDiagnosticErrorListener () {
30860
- if (hasRequiredDiagnosticErrorListener) return DiagnosticErrorListener;
30861
- hasRequiredDiagnosticErrorListener = 1;
30862
- /*!
30863
- * Copyright 2016 The ANTLR Project. All rights reserved.
30864
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
30865
- */
30866
- var __decorate = (DiagnosticErrorListener && DiagnosticErrorListener.__decorate) || function (decorators, target, key, desc) {
30867
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30868
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30869
- 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;
30870
- return c > 3 && r && Object.defineProperty(target, key, r), r;
30871
- };
30872
- var __param = (DiagnosticErrorListener && DiagnosticErrorListener.__param) || function (paramIndex, decorator) {
30873
- return function (target, key) { decorator(target, key, paramIndex); }
30874
- };
30875
- Object.defineProperty(DiagnosticErrorListener, "__esModule", { value: true });
30876
- DiagnosticErrorListener.DiagnosticErrorListener = void 0;
30877
- const BitSet_1 = requireBitSet();
30878
- const Decorators_1 = requireDecorators();
30879
- const Interval_1 = requireInterval();
30880
- /**
30881
- * This implementation of {@link ANTLRErrorListener} can be used to identify
30882
- * certain potential correctness and performance problems in grammars. "Reports"
30883
- * are made by calling {@link Parser#notifyErrorListeners} with the appropriate
30884
- * message.
30885
- *
30886
- * * **Ambiguities**: These are cases where more than one path through the
30887
- * grammar can match the input.
30888
- * * **Weak context sensitivity**: These are cases where full-context
30889
- * prediction resolved an SLL conflict to a unique alternative which equaled the
30890
- * minimum alternative of the SLL conflict.
30891
- * * **Strong (forced) context sensitivity**: These are cases where the
30892
- * full-context prediction resolved an SLL conflict to a unique alternative,
30893
- * *and* the minimum alternative of the SLL conflict was found to not be
30894
- * a truly viable alternative. Two-stage parsing cannot be used for inputs where
30895
- * this situation occurs.
30896
- *
30897
- * @author Sam Harwell
30898
- */
30899
- let DiagnosticErrorListener$1 = class DiagnosticErrorListener {
30900
- /**
30901
- * Initializes a new instance of {@link DiagnosticErrorListener}, specifying
30902
- * whether all ambiguities or only exact ambiguities are reported.
30903
- *
30904
- * @param exactOnly `true` to report only exact ambiguities, otherwise
30905
- * `false` to report all ambiguities. Defaults to true.
30906
- */
30907
- constructor(exactOnly = true) {
30908
- this.exactOnly = exactOnly;
30909
- this.exactOnly = exactOnly;
30910
- }
30911
- syntaxError(
30912
- /*@NotNull*/
30913
- recognizer, offendingSymbol, line, charPositionInLine,
30914
- /*@NotNull*/
30915
- msg, e) {
30916
- // intentionally empty
30917
- }
30918
- reportAmbiguity(recognizer, dfa, startIndex, stopIndex, exact, ambigAlts, configs) {
30919
- if (this.exactOnly && !exact) {
30920
- return;
30921
- }
30922
- let decision = this.getDecisionDescription(recognizer, dfa);
30923
- let conflictingAlts = this.getConflictingAlts(ambigAlts, configs);
30924
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
30925
- let message = `reportAmbiguity d=${decision}: ambigAlts=${conflictingAlts}, input='${text}'`;
30926
- recognizer.notifyErrorListeners(message);
30927
- }
30928
- reportAttemptingFullContext(recognizer, dfa, startIndex, stopIndex, conflictingAlts, conflictState) {
30929
- let decision = this.getDecisionDescription(recognizer, dfa);
30930
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
30931
- let message = `reportAttemptingFullContext d=${decision}, input='${text}'`;
30932
- recognizer.notifyErrorListeners(message);
30933
- }
30934
- reportContextSensitivity(recognizer, dfa, startIndex, stopIndex, prediction, acceptState) {
30935
- let decision = this.getDecisionDescription(recognizer, dfa);
30936
- let text = recognizer.inputStream.getText(Interval_1.Interval.of(startIndex, stopIndex));
30937
- let message = `reportContextSensitivity d=${decision}, input='${text}'`;
30938
- recognizer.notifyErrorListeners(message);
30939
- }
30940
- getDecisionDescription(recognizer, dfa) {
30941
- let decision = dfa.decision;
30942
- let ruleIndex = dfa.atnStartState.ruleIndex;
30943
- let ruleNames = recognizer.ruleNames;
30944
- if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
30945
- return decision.toString();
30946
- }
30947
- let ruleName = ruleNames[ruleIndex];
30948
- if (!ruleName) {
30949
- return decision.toString();
30950
- }
30951
- return `${decision} (${ruleName})`;
30952
- }
30953
- /**
30954
- * Computes the set of conflicting or ambiguous alternatives from a
30955
- * configuration set, if that information was not already provided by the
30956
- * parser.
30957
- *
30958
- * @param reportedAlts The set of conflicting or ambiguous alternatives, as
30959
- * reported by the parser.
30960
- * @param configs The conflicting or ambiguous configuration set.
30961
- * @returns Returns `reportedAlts` if it is not `undefined`, otherwise
30962
- * returns the set of alternatives represented in `configs`.
30963
- */
30964
- getConflictingAlts(reportedAlts, configs) {
30965
- if (reportedAlts != null) {
30966
- return reportedAlts;
30967
- }
30968
- let result = new BitSet_1.BitSet();
30969
- for (let config of configs) {
30970
- result.set(config.alt);
30971
- }
30972
- return result;
30973
- }
30974
- };
30975
- __decorate([
30976
- Decorators_1.Override
30977
- ], DiagnosticErrorListener$1.prototype, "syntaxError", null);
30978
- __decorate([
30979
- Decorators_1.Override,
30980
- __param(0, Decorators_1.NotNull),
30981
- __param(1, Decorators_1.NotNull),
30982
- __param(6, Decorators_1.NotNull)
30983
- ], DiagnosticErrorListener$1.prototype, "reportAmbiguity", null);
30984
- __decorate([
30985
- Decorators_1.Override,
30986
- __param(0, Decorators_1.NotNull),
30987
- __param(1, Decorators_1.NotNull),
30988
- __param(5, Decorators_1.NotNull)
30989
- ], DiagnosticErrorListener$1.prototype, "reportAttemptingFullContext", null);
30990
- __decorate([
30991
- Decorators_1.Override,
30992
- __param(0, Decorators_1.NotNull),
30993
- __param(1, Decorators_1.NotNull),
30994
- __param(5, Decorators_1.NotNull)
30995
- ], DiagnosticErrorListener$1.prototype, "reportContextSensitivity", null);
30996
- __decorate([
30997
- __param(0, Decorators_1.NotNull),
30998
- __param(1, Decorators_1.NotNull)
30999
- ], DiagnosticErrorListener$1.prototype, "getDecisionDescription", null);
31000
- __decorate([
31001
- Decorators_1.NotNull,
31002
- __param(1, Decorators_1.NotNull)
31003
- ], DiagnosticErrorListener$1.prototype, "getConflictingAlts", null);
31004
- DiagnosticErrorListener.DiagnosticErrorListener = DiagnosticErrorListener$1;
31005
-
31006
- return DiagnosticErrorListener;
31007
- }
31008
-
31009
- var LexerInterpreter = {};
31010
-
31011
- var hasRequiredLexerInterpreter;
31012
-
31013
- function requireLexerInterpreter () {
31014
- if (hasRequiredLexerInterpreter) return LexerInterpreter;
31015
- hasRequiredLexerInterpreter = 1;
31016
- /*!
31017
- * Copyright 2016 The ANTLR Project. All rights reserved.
31018
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31019
- */
31020
- var __decorate = (LexerInterpreter && LexerInterpreter.__decorate) || function (decorators, target, key, desc) {
31021
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31022
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31023
- 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;
31024
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31025
- };
31026
- var __param = (LexerInterpreter && LexerInterpreter.__param) || function (paramIndex, decorator) {
31027
- return function (target, key) { decorator(target, key, paramIndex); }
31028
- };
31029
- Object.defineProperty(LexerInterpreter, "__esModule", { value: true });
31030
- LexerInterpreter.LexerInterpreter = void 0;
31031
- const Lexer_1 = requireLexer();
31032
- const LexerATNSimulator_1 = requireLexerATNSimulator();
31033
- const Decorators_1 = requireDecorators();
31034
- const Decorators_2 = requireDecorators();
31035
- let LexerInterpreter$1 = class LexerInterpreter extends Lexer_1.Lexer {
31036
- constructor(grammarFileName, vocabulary, ruleNames, channelNames, modeNames, atn, input) {
31037
- super(input);
31038
- if (atn.grammarType !== 0 /* LEXER */) {
31039
- throw new Error("IllegalArgumentException: The ATN must be a lexer ATN.");
31040
- }
31041
- this._grammarFileName = grammarFileName;
31042
- this._atn = atn;
31043
- this._ruleNames = ruleNames.slice(0);
31044
- this._channelNames = channelNames.slice(0);
31045
- this._modeNames = modeNames.slice(0);
31046
- this._vocabulary = vocabulary;
31047
- this._interp = new LexerATNSimulator_1.LexerATNSimulator(atn, this);
31048
- }
31049
- get atn() {
31050
- return this._atn;
31051
- }
31052
- get grammarFileName() {
31053
- return this._grammarFileName;
31054
- }
31055
- get ruleNames() {
31056
- return this._ruleNames;
31057
- }
31058
- get channelNames() {
31059
- return this._channelNames;
31060
- }
31061
- get modeNames() {
31062
- return this._modeNames;
31063
- }
31064
- get vocabulary() {
31065
- return this._vocabulary;
31066
- }
31067
- };
31068
- __decorate([
31069
- Decorators_1.NotNull
31070
- ], LexerInterpreter$1.prototype, "_vocabulary", void 0);
31071
- __decorate([
31072
- Decorators_2.Override
31073
- ], LexerInterpreter$1.prototype, "atn", null);
31074
- __decorate([
31075
- Decorators_2.Override
31076
- ], LexerInterpreter$1.prototype, "grammarFileName", null);
31077
- __decorate([
31078
- Decorators_2.Override
31079
- ], LexerInterpreter$1.prototype, "ruleNames", null);
31080
- __decorate([
31081
- Decorators_2.Override
31082
- ], LexerInterpreter$1.prototype, "channelNames", null);
31083
- __decorate([
31084
- Decorators_2.Override
31085
- ], LexerInterpreter$1.prototype, "modeNames", null);
31086
- __decorate([
31087
- Decorators_2.Override
31088
- ], LexerInterpreter$1.prototype, "vocabulary", null);
31089
- LexerInterpreter$1 = __decorate([
31090
- __param(1, Decorators_1.NotNull)
31091
- ], LexerInterpreter$1);
31092
- LexerInterpreter.LexerInterpreter = LexerInterpreter$1;
31093
-
31094
- return LexerInterpreter;
31095
- }
31096
-
31097
- var ParserErrorListener = {};
31098
-
31099
- var hasRequiredParserErrorListener;
31100
-
31101
- function requireParserErrorListener () {
31102
- if (hasRequiredParserErrorListener) return ParserErrorListener;
31103
- hasRequiredParserErrorListener = 1;
31104
- /*!
31105
- * Copyright 2016 The ANTLR Project. All rights reserved.
31106
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31107
- */
31108
- Object.defineProperty(ParserErrorListener, "__esModule", { value: true });
31109
-
31110
- return ParserErrorListener;
31111
- }
31112
-
31113
- var RuleContextWithAltNum = {};
31114
-
31115
- var hasRequiredRuleContextWithAltNum;
31116
-
31117
- function requireRuleContextWithAltNum () {
31118
- if (hasRequiredRuleContextWithAltNum) return RuleContextWithAltNum;
31119
- hasRequiredRuleContextWithAltNum = 1;
31120
- /*!
31121
- * Copyright 2016 The ANTLR Project. All rights reserved.
31122
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31123
- */
31124
- var __decorate = (RuleContextWithAltNum && RuleContextWithAltNum.__decorate) || function (decorators, target, key, desc) {
31125
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31126
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31127
- 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;
31128
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31129
- };
31130
- Object.defineProperty(RuleContextWithAltNum, "__esModule", { value: true });
31131
- RuleContextWithAltNum.RuleContextWithAltNum = void 0;
31132
- // ConvertTo-TS run at 2016-10-04T11:26:57.4741196-07:00
31133
- const ATN_1 = requireATN();
31134
- const Decorators_1 = requireDecorators();
31135
- const ParserRuleContext_1 = requireParserRuleContext();
31136
- /** A handy class for use with
31137
- *
31138
- * options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;}
31139
- *
31140
- * that provides a backing field / impl for the outer alternative number
31141
- * matched for an internal parse tree node.
31142
- *
31143
- * I'm only putting into Java runtime as I'm certain I'm the only one that
31144
- * will really every use this.
31145
- */
31146
- let RuleContextWithAltNum$1 = class RuleContextWithAltNum extends ParserRuleContext_1.ParserRuleContext {
31147
- constructor(parent, invokingStateNumber) {
31148
- if (invokingStateNumber !== undefined) {
31149
- super(parent, invokingStateNumber);
31150
- }
31151
- else {
31152
- super();
31153
- }
31154
- this._altNumber = ATN_1.ATN.INVALID_ALT_NUMBER;
31155
- }
31156
- get altNumber() {
31157
- return this._altNumber;
31158
- }
31159
- // @Override
31160
- set altNumber(altNum) {
31161
- this._altNumber = altNum;
31162
- }
31163
- };
31164
- __decorate([
31165
- Decorators_1.Override
31166
- ], RuleContextWithAltNum$1.prototype, "altNumber", null);
31167
- RuleContextWithAltNum.RuleContextWithAltNum = RuleContextWithAltNum$1;
31168
-
31169
- return RuleContextWithAltNum;
31170
- }
31171
-
31172
- var RuleDependency = {};
31173
-
31174
- var hasRequiredRuleDependency;
31175
-
31176
- function requireRuleDependency () {
31177
- if (hasRequiredRuleDependency) return RuleDependency;
31178
- hasRequiredRuleDependency = 1;
31179
- /*!
31180
- * Copyright 2016 The ANTLR Project. All rights reserved.
31181
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31182
- */
31183
- Object.defineProperty(RuleDependency, "__esModule", { value: true });
31184
- RuleDependency.RuleDependency = void 0;
31185
- /**
31186
- * Declares a dependency upon a grammar rule, along with a set of zero or more dependent rules.
31187
- *
31188
- * Version numbers within a grammar should be assigned on a monotonically increasing basis to allow for accurate
31189
- * tracking of dependent rules.
31190
- *
31191
- * @author Sam Harwell
31192
- */
31193
- function RuleDependency$1(dependency) {
31194
- return (target, propertyKey, propertyDescriptor) => {
31195
- // intentionally empty
31196
- };
31197
- }
31198
- RuleDependency.RuleDependency = RuleDependency$1;
31199
-
31200
- return RuleDependency;
31201
- }
31202
-
31203
- var RuleVersion = {};
31204
-
31205
- var hasRequiredRuleVersion;
31206
-
31207
- function requireRuleVersion () {
31208
- if (hasRequiredRuleVersion) return RuleVersion;
31209
- hasRequiredRuleVersion = 1;
31210
- /*!
31211
- * Copyright 2016 The ANTLR Project. All rights reserved.
31212
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31213
- */
31214
- Object.defineProperty(RuleVersion, "__esModule", { value: true });
31215
- RuleVersion.RuleVersion = void 0;
31216
- /**
31217
- *
31218
- * @author Sam Harwell
31219
- */
31220
- function RuleVersion$1(version) {
31221
- return (target, propertyKey, propertyDescriptor) => {
31222
- // intentionally empty
31223
- };
31224
- }
31225
- RuleVersion.RuleVersion = RuleVersion$1;
31226
-
31227
- return RuleVersion;
31228
- }
31229
-
31230
- var TokenFactory = {};
31231
-
31232
- var hasRequiredTokenFactory;
31233
-
31234
- function requireTokenFactory () {
31235
- if (hasRequiredTokenFactory) return TokenFactory;
31236
- hasRequiredTokenFactory = 1;
31237
- /*!
31238
- * Copyright 2016 The ANTLR Project. All rights reserved.
31239
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31240
- */
31241
- Object.defineProperty(TokenFactory, "__esModule", { value: true });
31242
-
31243
- return TokenFactory;
31244
- }
31245
-
31246
- var TokenSource = {};
31247
-
31248
- var hasRequiredTokenSource;
31249
-
31250
- function requireTokenSource () {
31251
- if (hasRequiredTokenSource) return TokenSource;
31252
- hasRequiredTokenSource = 1;
31253
- /*!
31254
- * Copyright 2016 The ANTLR Project. All rights reserved.
31255
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31256
- */
31257
- Object.defineProperty(TokenSource, "__esModule", { value: true });
31258
-
31259
- return TokenSource;
31260
- }
31261
-
31262
- var TokenStream = {};
31263
-
31264
- var hasRequiredTokenStream;
31265
-
31266
- function requireTokenStream () {
31267
- if (hasRequiredTokenStream) return TokenStream;
31268
- hasRequiredTokenStream = 1;
31269
- /*!
31270
- * Copyright 2016 The ANTLR Project. All rights reserved.
31271
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31272
- */
31273
- Object.defineProperty(TokenStream, "__esModule", { value: true });
31274
-
31275
- return TokenStream;
31276
- }
31277
-
31278
- var TokenStreamRewriter = {};
31279
-
31280
- var hasRequiredTokenStreamRewriter;
31281
-
31282
- function requireTokenStreamRewriter () {
31283
- if (hasRequiredTokenStreamRewriter) return TokenStreamRewriter;
31284
- hasRequiredTokenStreamRewriter = 1;
31285
- /*!
31286
- * Copyright 2016 The ANTLR Project. All rights reserved.
31287
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31288
- */
31289
- var __decorate = (TokenStreamRewriter && TokenStreamRewriter.__decorate) || function (decorators, target, key, desc) {
31290
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
31291
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
31292
- 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;
31293
- return c > 3 && r && Object.defineProperty(target, key, r), r;
31294
- };
31295
- Object.defineProperty(TokenStreamRewriter, "__esModule", { value: true });
31296
- TokenStreamRewriter.RewriteOperation = TokenStreamRewriter.TokenStreamRewriter = void 0;
31297
- // ConvertTo-TS run at 2016-10-04T11:26:58.1768850-07:00
31298
- const Interval_1 = requireInterval();
31299
- const Decorators_1 = requireDecorators();
31300
- const Token_1 = requireToken();
31301
- /**
31302
- * Useful for rewriting out a buffered input token stream after doing some
31303
- * augmentation or other manipulations on it.
31304
- *
31305
- * You can insert stuff, replace, and delete chunks. Note that the operations
31306
- * are done lazily--only if you convert the buffer to a {@link String} with
31307
- * {@link TokenStream#getText()}. This is very efficient because you are not
31308
- * moving data around all the time. As the buffer of tokens is converted to
31309
- * strings, the {@link #getText()} method(s) scan the input token stream and
31310
- * check to see if there is an operation at the current index. If so, the
31311
- * operation is done and then normal {@link String} rendering continues on the
31312
- * buffer. This is like having multiple Turing machine instruction streams
31313
- * (programs) operating on a single input tape. :)
31314
- *
31315
- * This rewriter makes no modifications to the token stream. It does not ask the
31316
- * stream to fill itself up nor does it advance the input cursor. The token
31317
- * stream `TokenStream.index` will return the same value before and
31318
- * after any {@link #getText()} call.
31319
- *
31320
- * The rewriter only works on tokens that you have in the buffer and ignores the
31321
- * current input cursor. If you are buffering tokens on-demand, calling
31322
- * {@link #getText()} halfway through the input will only do rewrites for those
31323
- * tokens in the first half of the file.
31324
- *
31325
- * Since the operations are done lazily at {@link #getText}-time, operations do
31326
- * not screw up the token index values. That is, an insert operation at token
31327
- * index `i` does not change the index values for tokens
31328
- * `i`+1..n-1.
31329
- *
31330
- * Because operations never actually alter the buffer, you may always get the
31331
- * original token stream back without undoing anything. Since the instructions
31332
- * are queued up, you can easily simulate transactions and roll back any changes
31333
- * if there is an error just by removing instructions. For example,
31334
- *
31335
- * ```
31336
- * CharStream input = new ANTLRFileStream("input");
31337
- * TLexer lex = new TLexer(input);
31338
- * CommonTokenStream tokens = new CommonTokenStream(lex);
31339
- * T parser = new T(tokens);
31340
- * TokenStreamRewriter rewriter = new TokenStreamRewriter(tokens);
31341
- * parser.startRule();
31342
- * ```
31343
- *
31344
- * Then in the rules, you can execute (assuming rewriter is visible):
31345
- *
31346
- * ```
31347
- * Token t,u;
31348
- * ...
31349
- * rewriter.insertAfter(t, "text to put after t");}
31350
- * rewriter.insertAfter(u, "text after u");}
31351
- * System.out.println(rewriter.getText());
31352
- * ```
31353
- *
31354
- * You can also have multiple "instruction streams" and get multiple rewrites
31355
- * from a single pass over the input. Just name the instruction streams and use
31356
- * that name again when printing the buffer. This could be useful for generating
31357
- * a C file and also its header file--all from the same buffer:
31358
- *
31359
- * ```
31360
- * rewriter.insertAfter("pass1", t, "text to put after t");}
31361
- * rewriter.insertAfter("pass2", u, "text after u");}
31362
- * System.out.println(rewriter.getText("pass1"));
31363
- * System.out.println(rewriter.getText("pass2"));
31364
- * ```
31365
- *
31366
- * If you don't use named rewrite streams, a "default" stream is used as the
31367
- * first example shows.
31368
- */
31369
- let TokenStreamRewriter$1 = class TokenStreamRewriter {
31370
- constructor(tokens) {
31371
- this.tokens = tokens;
31372
- this.programs = new Map();
31373
- this.programs.set(TokenStreamRewriter.DEFAULT_PROGRAM_NAME, []);
31374
- this.lastRewriteTokenIndexes = new Map();
31375
- }
31376
- getTokenStream() {
31377
- return this.tokens;
31378
- }
31379
- rollback(instructionIndex, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31380
- let is = this.programs.get(programName);
31381
- if (is != null) {
31382
- this.programs.set(programName, is.slice(TokenStreamRewriter.MIN_TOKEN_INDEX, instructionIndex));
31383
- }
31384
- }
31385
- deleteProgram(programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31386
- this.rollback(TokenStreamRewriter.MIN_TOKEN_INDEX, programName);
31387
- }
31388
- insertAfter(tokenOrIndex, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31389
- let index;
31390
- if (typeof tokenOrIndex === "number") {
31391
- index = tokenOrIndex;
31392
- }
31393
- else {
31394
- index = tokenOrIndex.tokenIndex;
31395
- }
31396
- // to insert after, just insert before next index (even if past end)
31397
- let rewrites = this.getProgram(programName);
31398
- let op = new InsertAfterOp(this.tokens, index, rewrites.length, text);
31399
- rewrites.push(op);
31400
- }
31401
- insertBefore(tokenOrIndex, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31402
- let index;
31403
- if (typeof tokenOrIndex === "number") {
31404
- index = tokenOrIndex;
31405
- }
31406
- else {
31407
- index = tokenOrIndex.tokenIndex;
31408
- }
31409
- let rewrites = this.getProgram(programName);
31410
- let op = new InsertBeforeOp(this.tokens, index, rewrites.length, text);
31411
- rewrites.push(op);
31412
- }
31413
- replaceSingle(index, text) {
31414
- if (typeof index === "number") {
31415
- this.replace(index, index, text);
31416
- }
31417
- else {
31418
- this.replace(index, index, text);
31419
- }
31420
- }
31421
- replace(from, to, text, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31422
- if (typeof from !== "number") {
31423
- from = from.tokenIndex;
31424
- }
31425
- if (typeof to !== "number") {
31426
- to = to.tokenIndex;
31427
- }
31428
- if (from > to || from < 0 || to < 0 || to >= this.tokens.size) {
31429
- throw new RangeError(`replace: range invalid: ${from}..${to}(size=${this.tokens.size})`);
31430
- }
31431
- let rewrites = this.getProgram(programName);
31432
- let op = new ReplaceOp(this.tokens, from, to, rewrites.length, text);
31433
- rewrites.push(op);
31434
- }
31435
- delete(from, to, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31436
- if (to === undefined) {
31437
- to = from;
31438
- }
31439
- if (typeof from === "number") {
31440
- this.replace(from, to, "", programName);
31441
- }
31442
- else {
31443
- this.replace(from, to, "", programName);
31444
- }
31445
- }
31446
- getLastRewriteTokenIndex(programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31447
- let I = this.lastRewriteTokenIndexes.get(programName);
31448
- if (I == null) {
31449
- return -1;
31450
- }
31451
- return I;
31452
- }
31453
- setLastRewriteTokenIndex(programName, i) {
31454
- this.lastRewriteTokenIndexes.set(programName, i);
31455
- }
31456
- getProgram(name) {
31457
- let is = this.programs.get(name);
31458
- if (is == null) {
31459
- is = this.initializeProgram(name);
31460
- }
31461
- return is;
31462
- }
31463
- initializeProgram(name) {
31464
- let is = [];
31465
- this.programs.set(name, is);
31466
- return is;
31467
- }
31468
- getText(intervalOrProgram, programName = TokenStreamRewriter.DEFAULT_PROGRAM_NAME) {
31469
- let interval;
31470
- if (intervalOrProgram instanceof Interval_1.Interval) {
31471
- interval = intervalOrProgram;
31472
- }
31473
- else {
31474
- interval = Interval_1.Interval.of(0, this.tokens.size - 1);
31475
- }
31476
- if (typeof intervalOrProgram === "string") {
31477
- programName = intervalOrProgram;
31478
- }
31479
- let rewrites = this.programs.get(programName);
31480
- let start = interval.a;
31481
- let stop = interval.b;
31482
- // ensure start/end are in range
31483
- if (stop > this.tokens.size - 1) {
31484
- stop = this.tokens.size - 1;
31485
- }
31486
- if (start < 0) {
31487
- start = 0;
31488
- }
31489
- if (rewrites == null || rewrites.length === 0) {
31490
- return this.tokens.getText(interval); // no instructions to execute
31491
- }
31492
- let buf = [];
31493
- // First, optimize instruction stream
31494
- let indexToOp = this.reduceToSingleOperationPerIndex(rewrites);
31495
- // Walk buffer, executing instructions and emitting tokens
31496
- let i = start;
31497
- while (i <= stop && i < this.tokens.size) {
31498
- let op = indexToOp.get(i);
31499
- indexToOp.delete(i); // remove so any left have index size-1
31500
- let t = this.tokens.get(i);
31501
- if (op == null) {
31502
- // no operation at that index, just dump token
31503
- if (t.type !== Token_1.Token.EOF) {
31504
- buf.push(String(t.text));
31505
- }
31506
- i++; // move to next token
31507
- }
31508
- else {
31509
- i = op.execute(buf); // execute operation and skip
31510
- }
31511
- }
31512
- // include stuff after end if it's last index in buffer
31513
- // So, if they did an insertAfter(lastValidIndex, "foo"), include
31514
- // foo if end==lastValidIndex.
31515
- if (stop === this.tokens.size - 1) {
31516
- // Scan any remaining operations after last token
31517
- // should be included (they will be inserts).
31518
- for (let op of indexToOp.values()) {
31519
- if (op.index >= this.tokens.size - 1) {
31520
- buf.push(op.text.toString());
31521
- }
31522
- }
31523
- }
31524
- return buf.join("");
31525
- }
31526
- /** We need to combine operations and report invalid operations (like
31527
- * overlapping replaces that are not completed nested). Inserts to
31528
- * same index need to be combined etc... Here are the cases:
31529
- *
31530
- * I.i.u I.j.v leave alone, nonoverlapping
31531
- * I.i.u I.i.v combine: Iivu
31532
- *
31533
- * R.i-j.u R.x-y.v | i-j in x-y delete first R
31534
- * R.i-j.u R.i-j.v delete first R
31535
- * R.i-j.u R.x-y.v | x-y in i-j ERROR
31536
- * R.i-j.u R.x-y.v | boundaries overlap ERROR
31537
- *
31538
- * Delete special case of replace (text==undefined):
31539
- * D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
31540
- *
31541
- * I.i.u R.x-y.v | i in (x+1)-y delete I (since insert before
31542
- * we're not deleting i)
31543
- * I.i.u R.x-y.v | i not in (x+1)-y leave alone, nonoverlapping
31544
- * R.x-y.v I.i.u | i in x-y ERROR
31545
- * R.x-y.v I.x.u R.x-y.uv (combine, delete I)
31546
- * R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
31547
- *
31548
- * I.i.u = insert u before op @ index i
31549
- * R.x-y.u = replace x-y indexed tokens with u
31550
- *
31551
- * First we need to examine replaces. For any replace op:
31552
- *
31553
- * 1. wipe out any insertions before op within that range.
31554
- * 2. Drop any replace op before that is contained completely within
31555
- * that range.
31556
- * 3. Throw exception upon boundary overlap with any previous replace.
31557
- *
31558
- * Then we can deal with inserts:
31559
- *
31560
- * 1. for any inserts to same index, combine even if not adjacent.
31561
- * 2. for any prior replace with same left boundary, combine this
31562
- * insert with replace and delete this replace.
31563
- * 3. throw exception if index in same range as previous replace
31564
- *
31565
- * Don't actually delete; make op undefined in list. Easier to walk list.
31566
- * Later we can throw as we add to index &rarr; op map.
31567
- *
31568
- * Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
31569
- * inserted stuff would be before the replace range. But, if you
31570
- * add tokens in front of a method body '{' and then delete the method
31571
- * body, I think the stuff before the '{' you added should disappear too.
31572
- *
31573
- * Return a map from token index to operation.
31574
- */
31575
- reduceToSingleOperationPerIndex(rewrites) {
31576
- // console.log(`rewrites=[${Utils.join(rewrites, ", ")}]`);
31577
- // WALK REPLACES
31578
- for (let i = 0; i < rewrites.length; i++) {
31579
- let op = rewrites[i];
31580
- if (op == null) {
31581
- continue;
31582
- }
31583
- if (!(op instanceof ReplaceOp)) {
31584
- continue;
31585
- }
31586
- let rop = op;
31587
- // Wipe prior inserts within range
31588
- let inserts = this.getKindOfOps(rewrites, InsertBeforeOp, i);
31589
- for (let iop of inserts) {
31590
- if (iop.index === rop.index) {
31591
- // E.g., insert before 2, delete 2..2; update replace
31592
- // text to include insert before, kill insert
31593
- rewrites[iop.instructionIndex] = undefined;
31594
- rop.text = iop.text.toString() + (rop.text != null ? rop.text.toString() : "");
31595
- }
31596
- else if (iop.index > rop.index && iop.index <= rop.lastIndex) {
31597
- // delete insert as it's a no-op.
31598
- rewrites[iop.instructionIndex] = undefined;
31599
- }
31600
- }
31601
- // Drop any prior replaces contained within
31602
- let prevReplaces = this.getKindOfOps(rewrites, ReplaceOp, i);
31603
- for (let prevRop of prevReplaces) {
31604
- if (prevRop.index >= rop.index && prevRop.lastIndex <= rop.lastIndex) {
31605
- // delete replace as it's a no-op.
31606
- rewrites[prevRop.instructionIndex] = undefined;
31607
- continue;
31608
- }
31609
- // throw exception unless disjoint or identical
31610
- let disjoint = prevRop.lastIndex < rop.index || prevRop.index > rop.lastIndex;
31611
- // Delete special case of replace (text==null):
31612
- // D.i-j.u D.x-y.v | boundaries overlap combine to max(min)..max(right)
31613
- if (prevRop.text == null && rop.text == null && !disjoint) {
31614
- // console.log(`overlapping deletes: ${prevRop}, ${rop}`);
31615
- rewrites[prevRop.instructionIndex] = undefined; // kill first delete
31616
- rop.index = Math.min(prevRop.index, rop.index);
31617
- rop.lastIndex = Math.max(prevRop.lastIndex, rop.lastIndex);
31618
- // console.log(`new rop ${rop}`);
31619
- }
31620
- else if (!disjoint) {
31621
- throw new Error(`replace op boundaries of ${rop} overlap with previous ${prevRop}`);
31622
- }
31623
- }
31624
- }
31625
- // WALK INSERTS
31626
- for (let i = 0; i < rewrites.length; i++) {
31627
- let op = rewrites[i];
31628
- if (op == null) {
31629
- continue;
31630
- }
31631
- if (!(op instanceof InsertBeforeOp)) {
31632
- continue;
31633
- }
31634
- let iop = op;
31635
- // combine current insert with prior if any at same index
31636
- let prevInserts = this.getKindOfOps(rewrites, InsertBeforeOp, i);
31637
- for (let prevIop of prevInserts) {
31638
- if (prevIop.index === iop.index) {
31639
- if (prevIop instanceof InsertAfterOp) {
31640
- iop.text = this.catOpText(prevIop.text, iop.text);
31641
- rewrites[prevIop.instructionIndex] = undefined;
31642
- }
31643
- else if (prevIop instanceof InsertBeforeOp) { // combine objects
31644
- // convert to strings...we're in process of toString'ing
31645
- // whole token buffer so no lazy eval issue with any templates
31646
- iop.text = this.catOpText(iop.text, prevIop.text);
31647
- // delete redundant prior insert
31648
- rewrites[prevIop.instructionIndex] = undefined;
31649
- }
31650
- }
31651
- }
31652
- // look for replaces where iop.index is in range; error
31653
- let prevReplaces = this.getKindOfOps(rewrites, ReplaceOp, i);
31654
- for (let rop of prevReplaces) {
31655
- if (iop.index === rop.index) {
31656
- rop.text = this.catOpText(iop.text, rop.text);
31657
- rewrites[i] = undefined; // delete current insert
31658
- continue;
31659
- }
31660
- if (iop.index >= rop.index && iop.index <= rop.lastIndex) {
31661
- throw new Error(`insert op ${iop} within boundaries of previous ${rop}`);
31662
- }
31663
- }
31664
- }
31665
- // console.log(`rewrites after=[${Utils.join(rewrites, ", ")}]`);
31666
- let m = new Map();
31667
- for (let op of rewrites) {
31668
- if (op == null) {
31669
- // ignore deleted ops
31670
- continue;
31671
- }
31672
- if (m.get(op.index) != null) {
31673
- throw new Error("should only be one op per index");
31674
- }
31675
- m.set(op.index, op);
31676
- }
31677
- // console.log(`index to op: ${m}`);
31678
- return m;
31679
- }
31680
- catOpText(a, b) {
31681
- let x = "";
31682
- let y = "";
31683
- if (a != null) {
31684
- x = a.toString();
31685
- }
31686
- if (b != null) {
31687
- y = b.toString();
31688
- }
31689
- return x + y;
31690
- }
31691
- /** Get all operations before an index of a particular kind */
31692
- getKindOfOps(rewrites, kind, before) {
31693
- let ops = [];
31694
- for (let i = 0; i < before && i < rewrites.length; i++) {
31695
- let op = rewrites[i];
31696
- if (op == null) {
31697
- // ignore deleted
31698
- continue;
31699
- }
31700
- if (op instanceof kind) {
31701
- ops.push(op);
31702
- }
31703
- }
31704
- return ops;
31705
- }
31706
- };
31707
- TokenStreamRewriter.TokenStreamRewriter = TokenStreamRewriter$1;
31708
- TokenStreamRewriter$1.DEFAULT_PROGRAM_NAME = "default";
31709
- TokenStreamRewriter$1.PROGRAM_INIT_SIZE = 100;
31710
- TokenStreamRewriter$1.MIN_TOKEN_INDEX = 0;
31711
- // Define the rewrite operation hierarchy
31712
- class RewriteOperation {
31713
- constructor(tokens, index, instructionIndex, text) {
31714
- this.tokens = tokens;
31715
- this.instructionIndex = instructionIndex;
31716
- this.index = index;
31717
- this.text = text === undefined ? "" : text;
31718
- }
31719
- /** Execute the rewrite operation by possibly adding to the buffer.
31720
- * Return the index of the next token to operate on.
31721
- */
31722
- execute(buf) {
31723
- return this.index;
31724
- }
31725
- toString() {
31726
- let opName = this.constructor.name;
31727
- let $index = opName.indexOf("$");
31728
- opName = opName.substring($index + 1, opName.length);
31729
- return "<" + opName + "@" + this.tokens.get(this.index) +
31730
- ":\"" + this.text + "\">";
31731
- }
31732
- }
31733
- __decorate([
31734
- Decorators_1.Override
31735
- ], RewriteOperation.prototype, "toString", null);
31736
- TokenStreamRewriter.RewriteOperation = RewriteOperation;
31737
- class InsertBeforeOp extends RewriteOperation {
31738
- constructor(tokens, index, instructionIndex, text) {
31739
- super(tokens, index, instructionIndex, text);
31740
- }
31741
- execute(buf) {
31742
- buf.push(this.text.toString());
31743
- if (this.tokens.get(this.index).type !== Token_1.Token.EOF) {
31744
- buf.push(String(this.tokens.get(this.index).text));
31745
- }
31746
- return this.index + 1;
31747
- }
31748
- }
31749
- __decorate([
31750
- Decorators_1.Override
31751
- ], InsertBeforeOp.prototype, "execute", null);
31752
- /** Distinguish between insert after/before to do the "insert afters"
31753
- * first and then the "insert befores" at same index. Implementation
31754
- * of "insert after" is "insert before index+1".
31755
- */
31756
- class InsertAfterOp extends InsertBeforeOp {
31757
- constructor(tokens, index, instructionIndex, text) {
31758
- super(tokens, index + 1, instructionIndex, text); // insert after is insert before index+1
31759
- }
31760
- }
31761
- /** I'm going to try replacing range from x..y with (y-x)+1 ReplaceOp
31762
- * instructions.
31763
- */
31764
- class ReplaceOp extends RewriteOperation {
31765
- constructor(tokens, from, to, instructionIndex, text) {
31766
- super(tokens, from, instructionIndex, text);
31767
- this.lastIndex = to;
31768
- }
31769
- execute(buf) {
31770
- if (this.text != null) {
31771
- buf.push(this.text.toString());
31772
- }
31773
- return this.lastIndex + 1;
31774
- }
31775
- toString() {
31776
- if (this.text == null) {
31777
- return "<DeleteOp@" + this.tokens.get(this.index) +
31778
- ".." + this.tokens.get(this.lastIndex) + ">";
31779
- }
31780
- return "<ReplaceOp@" + this.tokens.get(this.index) +
31781
- ".." + this.tokens.get(this.lastIndex) + ":\"" + this.text + "\">";
31782
- }
31783
- }
31784
- __decorate([
31785
- Decorators_1.Override
31786
- ], ReplaceOp.prototype, "execute", null);
31787
- __decorate([
31788
- Decorators_1.Override
31789
- ], ReplaceOp.prototype, "toString", null);
31790
-
31791
- return TokenStreamRewriter;
31792
- }
31793
-
31794
- var Vocabulary = {};
31795
-
31796
- var hasRequiredVocabulary;
31797
-
31798
- function requireVocabulary () {
31799
- if (hasRequiredVocabulary) return Vocabulary;
31800
- hasRequiredVocabulary = 1;
31801
- /*!
31802
- * Copyright 2016 The ANTLR Project. All rights reserved.
31803
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31804
- */
31805
- Object.defineProperty(Vocabulary, "__esModule", { value: true });
31806
-
31807
- return Vocabulary;
31808
- }
31809
-
31810
- var WritableToken = {};
31811
-
31812
- var hasRequiredWritableToken;
31813
-
31814
- function requireWritableToken () {
31815
- if (hasRequiredWritableToken) return WritableToken;
31816
- hasRequiredWritableToken = 1;
31817
- /*!
31818
- * Copyright 2016 The ANTLR Project. All rights reserved.
31819
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31820
- */
31821
- Object.defineProperty(WritableToken, "__esModule", { value: true });
31822
-
31823
- return WritableToken;
31824
- }
31825
-
31826
- var hasRequiredAntlr4ts;
31827
-
31828
- function requireAntlr4ts () {
31829
- if (hasRequiredAntlr4ts) return antlr4ts;
31830
- hasRequiredAntlr4ts = 1;
31831
- (function (exports) {
31832
- /*!
31833
- * Copyright 2016 The ANTLR Project. All rights reserved.
31834
- * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
31835
- */
31836
- var __createBinding = (antlr4ts && antlr4ts.__createBinding) || (Object.create ? (function(o, m, k, k2) {
31837
- if (k2 === undefined) k2 = k;
31838
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
31839
- }) : (function(o, m, k, k2) {
31840
- if (k2 === undefined) k2 = k;
31841
- o[k2] = m[k];
31842
- }));
31843
- var __exportStar = (antlr4ts && antlr4ts.__exportStar) || function(m, exports) {
31844
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31845
- };
31846
- Object.defineProperty(exports, "__esModule", { value: true });
31847
- __exportStar(requireANTLRErrorListener(), exports);
31848
- __exportStar(requireANTLRErrorStrategy(), exports);
31849
- // export * from "./ANTLRFileStream";
31850
- __exportStar(requireANTLRInputStream(), exports);
31851
- __exportStar(requireBailErrorStrategy(), exports);
31852
- __exportStar(requireBufferedTokenStream(), exports);
31853
- __exportStar(requireCharStream(), exports);
31854
- __exportStar(requireCharStreams(), exports);
31855
- __exportStar(requireCodePointBuffer(), exports);
31856
- __exportStar(requireCodePointCharStream(), exports);
31857
- __exportStar(requireCommonToken(), exports);
31858
- __exportStar(requireCommonTokenFactory(), exports);
31859
- __exportStar(requireCommonTokenStream(), exports);
31860
- __exportStar(requireConsoleErrorListener(), exports);
31861
- __exportStar(requireDefaultErrorStrategy(), exports);
31862
- __exportStar(requireDependents(), exports);
31863
- __exportStar(requireDiagnosticErrorListener(), exports);
31864
- __exportStar(requireFailedPredicateException(), exports);
31865
- __exportStar(requireInputMismatchException(), exports);
31866
- __exportStar(requireInterpreterRuleContext(), exports);
31867
- __exportStar(requireIntStream(), exports);
31868
- __exportStar(requireLexer(), exports);
31869
- __exportStar(requireLexerInterpreter(), exports);
31870
- __exportStar(requireLexerNoViableAltException(), exports);
31871
- __exportStar(requireListTokenSource(), exports);
31872
- __exportStar(requireNoViableAltException(), exports);
31873
- __exportStar(requireParser(), exports);
31874
- __exportStar(requireParserErrorListener(), exports);
31875
- __exportStar(requireParserInterpreter(), exports);
31876
- __exportStar(requireParserRuleContext(), exports);
31877
- __exportStar(requireProxyErrorListener(), exports);
31878
- __exportStar(requireProxyParserErrorListener(), exports);
31879
- __exportStar(requireRecognitionException(), exports);
31880
- __exportStar(requireRecognizer(), exports);
31881
- __exportStar(requireRuleContext(), exports);
31882
- __exportStar(requireRuleContextWithAltNum(), exports);
31883
- __exportStar(requireRuleDependency(), exports);
31884
- __exportStar(requireRuleVersion(), exports);
31885
- __exportStar(requireToken(), exports);
31886
- __exportStar(requireTokenFactory(), exports);
31887
- __exportStar(requireTokenSource(), exports);
31888
- __exportStar(requireTokenStream(), exports);
31889
- __exportStar(requireTokenStreamRewriter(), exports);
31890
- // export * from "./UnbufferedCharStream";
31891
- // export * from "./UnbufferedTokenStream";
31892
- __exportStar(requireVocabulary(), exports);
31893
- __exportStar(requireVocabularyImpl(), exports);
31894
- __exportStar(requireWritableToken(), exports);
31895
-
31896
- } (antlr4ts));
31897
- return antlr4ts;
31898
- }
31899
-
31900
- var antlr4tsExports = requireAntlr4ts();
31901
-
31902
30558
  var ATNExports = requireATN();
31903
30559
 
31904
30560
  var FailedPredicateExceptionExports = requireFailedPredicateException();
@@ -40613,9 +39269,9 @@ class IdentifierContext extends ParserRuleContextExports.ParserRuleContext {
40613
39269
  }
40614
39270
 
40615
39271
  function getParser(inputText) {
40616
- const inputStream = antlr4tsExports.CharStreams.fromString(inputText);
39272
+ const inputStream = CharStreams$1.fromString(inputText);
40617
39273
  const lexer = new BattleScriptLexer(inputStream);
40618
- const tokenStream = new antlr4tsExports.CommonTokenStream(lexer);
39274
+ const tokenStream = new CommonTokenStream$1(lexer);
40619
39275
  return new BattleScriptParser(tokenStream);
40620
39276
  }
40621
39277
  // Function to Parse and Convert BattleScript to JSON