Initial commit with Advoware proxy

This commit is contained in:
root
2025-10-19 14:57:07 +00:00
commit 273aa8b549
45771 changed files with 5534555 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { ATNType } from "./ATNType";
import { DecisionState } from "./DecisionState";
import { DFA } from "../dfa/DFA";
import { IntervalSet } from "../misc/IntervalSet";
import { LexerAction } from "./LexerAction";
import { PredictionContext } from "./PredictionContext";
import { RuleContext } from "../RuleContext";
import { RuleStartState } from "./RuleStartState";
import { RuleStopState } from "./RuleStopState";
import { TokensStartState } from "./TokensStartState";
/** */
export declare class ATN {
readonly states: ATNState[];
/** Each subrule/rule is a decision point and we must track them so we
* can go back later and build DFA predictors for them. This includes
* all the rules, subrules, optional blocks, ()+, ()* etc...
*/
decisionToState: DecisionState[];
/**
* Maps from rule index to starting state number.
*/
ruleToStartState: RuleStartState[];
/**
* Maps from rule index to stop state number.
*/
ruleToStopState: RuleStopState[];
modeNameToStartState: Map<string, TokensStartState>;
/**
* The type of the ATN.
*/
grammarType: ATNType;
/**
* The maximum value for any symbol recognized by a transition in the ATN.
*/
maxTokenType: number;
/**
* For lexer ATNs, this maps the rule index to the resulting token type.
* For parser ATNs, this maps the rule index to the generated bypass token
* type if the
* {@link ATNDeserializationOptions#isGenerateRuleBypassTransitions}
* deserialization option was specified; otherwise, this is `undefined`.
*/
ruleToTokenType: Int32Array;
/**
* For lexer ATNs, this is an array of {@link LexerAction} objects which may
* be referenced by action transitions in the ATN.
*/
lexerActions: LexerAction[];
modeToStartState: TokensStartState[];
private contextCache;
decisionToDFA: DFA[];
modeToDFA: DFA[];
LL1Table: Map<number, number>;
/** Used for runtime deserialization of ATNs from strings */
constructor(grammarType: ATNType, maxTokenType: number);
clearDFA(): void;
get contextCacheSize(): number;
getCachedContext(context: PredictionContext): PredictionContext;
getDecisionToDFA(): DFA[];
/** Compute the set of valid tokens that can occur starting in state `s`.
* If `ctx` is {@link PredictionContext#EMPTY_LOCAL}, the set of tokens will not include what can follow
* the rule surrounding `s`. In other words, the set will be
* restricted to tokens reachable staying within `s`'s rule.
*/
nextTokens(s: ATNState, /*@NotNull*/ ctx: PredictionContext): IntervalSet;
/**
* Compute the set of valid tokens that can occur starting in `s` and
* staying in same rule. {@link Token#EPSILON} is in set if we reach end of
* rule.
*/
nextTokens(/*@NotNull*/ s: ATNState): IntervalSet;
addState(state: ATNState): void;
removeState(state: ATNState): void;
defineMode(name: string, s: TokensStartState): void;
defineDecisionState(s: DecisionState): number;
getDecisionState(decision: number): DecisionState | undefined;
get numberOfDecisions(): number;
/**
* Computes the set of input symbols which could follow ATN state number
* `stateNumber` in the specified full `context`. This method
* considers the complete parser context, but does not evaluate semantic
* predicates (i.e. all predicates encountered during the calculation are
* assumed true). If a path in the ATN exists from the starting state to the
* {@link RuleStopState} of the outermost context without matching any
* symbols, {@link Token#EOF} is added to the returned set.
*
* If `context` is `undefined`, it is treated as
* {@link ParserRuleContext#EMPTY}.
*
* Note that this does NOT give you the set of all tokens that could
* appear at a given token position in the input phrase. In other words, it
* does not answer:
*
* > Given a specific partial input phrase, return the set of all
* > tokens that can follow the last token in the input phrase.
*
* The big difference is that with just the input, the parser could land
* right in the middle of a lookahead decision. Getting all
* *possible* tokens given a partial input stream is a separate
* computation. See https://github.com/antlr/antlr4/issues/1428
*
* For this function, we are specifying an ATN state and call stack to
* compute what token(s) can come next and specifically: outside of a
* lookahead decision. That is what you want for error reporting and
* recovery upon parse error.
*
* @param stateNumber the ATN state number
* @param context the full parse context
* @returns The set of potentially valid input symbols which could follow the
* specified state in the specified context.
* @ if the ATN does not contain a state with
* number `stateNumber`
*/
getExpectedTokens(stateNumber: number, context: RuleContext | undefined): IntervalSet;
}
export declare namespace ATN {
const INVALID_ALT_NUMBER: number;
}

View File

@@ -0,0 +1,221 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATN = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:25.1063510-07:00
const Array2DHashMap_1 = require("../misc/Array2DHashMap");
const DFA_1 = require("../dfa/DFA");
const IntervalSet_1 = require("../misc/IntervalSet");
const InvalidState_1 = require("./InvalidState");
const LL1Analyzer_1 = require("./LL1Analyzer");
const Decorators_1 = require("../Decorators");
const ObjectEqualityComparator_1 = require("../misc/ObjectEqualityComparator");
const PredictionContext_1 = require("./PredictionContext");
const Token_1 = require("../Token");
const assert = require("assert");
/** */
let ATN = class ATN {
/** Used for runtime deserialization of ATNs from strings */
constructor(grammarType, maxTokenType) {
this.states = [];
/** Each subrule/rule is a decision point and we must track them so we
* can go back later and build DFA predictors for them. This includes
* all the rules, subrules, optional blocks, ()+, ()* etc...
*/
this.decisionToState = [];
this.modeNameToStartState = new Map();
this.modeToStartState = [];
this.contextCache = new Array2DHashMap_1.Array2DHashMap(ObjectEqualityComparator_1.ObjectEqualityComparator.INSTANCE);
this.decisionToDFA = [];
this.modeToDFA = [];
this.LL1Table = new Map();
this.grammarType = grammarType;
this.maxTokenType = maxTokenType;
}
clearDFA() {
this.decisionToDFA = new Array(this.decisionToState.length);
for (let i = 0; i < this.decisionToDFA.length; i++) {
this.decisionToDFA[i] = new DFA_1.DFA(this.decisionToState[i], i);
}
this.modeToDFA = new Array(this.modeToStartState.length);
for (let i = 0; i < this.modeToDFA.length; i++) {
this.modeToDFA[i] = new DFA_1.DFA(this.modeToStartState[i]);
}
this.contextCache.clear();
this.LL1Table.clear();
}
get contextCacheSize() {
return this.contextCache.size;
}
getCachedContext(context) {
return PredictionContext_1.PredictionContext.getCachedContext(context, this.contextCache, new PredictionContext_1.PredictionContext.IdentityHashMap());
}
getDecisionToDFA() {
assert(this.decisionToDFA != null && this.decisionToDFA.length === this.decisionToState.length);
return this.decisionToDFA;
}
nextTokens(s, ctx) {
if (ctx) {
let anal = new LL1Analyzer_1.LL1Analyzer(this);
let next = anal.LOOK(s, ctx);
return next;
}
else {
if (s.nextTokenWithinRule) {
return s.nextTokenWithinRule;
}
s.nextTokenWithinRule = this.nextTokens(s, PredictionContext_1.PredictionContext.EMPTY_LOCAL);
s.nextTokenWithinRule.setReadonly(true);
return s.nextTokenWithinRule;
}
}
addState(state) {
state.atn = this;
state.stateNumber = this.states.length;
this.states.push(state);
}
removeState(state) {
// just replace the state, don't shift states in list
let invalidState = new InvalidState_1.InvalidState();
invalidState.atn = this;
invalidState.stateNumber = state.stateNumber;
this.states[state.stateNumber] = invalidState;
}
defineMode(name, s) {
this.modeNameToStartState.set(name, s);
this.modeToStartState.push(s);
this.modeToDFA.push(new DFA_1.DFA(s));
this.defineDecisionState(s);
}
defineDecisionState(s) {
this.decisionToState.push(s);
s.decision = this.decisionToState.length - 1;
this.decisionToDFA.push(new DFA_1.DFA(s, s.decision));
return s.decision;
}
getDecisionState(decision) {
if (this.decisionToState.length > 0) {
return this.decisionToState[decision];
}
return undefined;
}
get numberOfDecisions() {
return this.decisionToState.length;
}
/**
* Computes the set of input symbols which could follow ATN state number
* `stateNumber` in the specified full `context`. This method
* considers the complete parser context, but does not evaluate semantic
* predicates (i.e. all predicates encountered during the calculation are
* assumed true). If a path in the ATN exists from the starting state to the
* {@link RuleStopState} of the outermost context without matching any
* symbols, {@link Token#EOF} is added to the returned set.
*
* If `context` is `undefined`, it is treated as
* {@link ParserRuleContext#EMPTY}.
*
* Note that this does NOT give you the set of all tokens that could
* appear at a given token position in the input phrase. In other words, it
* does not answer:
*
* > Given a specific partial input phrase, return the set of all
* > tokens that can follow the last token in the input phrase.
*
* The big difference is that with just the input, the parser could land
* right in the middle of a lookahead decision. Getting all
* *possible* tokens given a partial input stream is a separate
* computation. See https://github.com/antlr/antlr4/issues/1428
*
* For this function, we are specifying an ATN state and call stack to
* compute what token(s) can come next and specifically: outside of a
* lookahead decision. That is what you want for error reporting and
* recovery upon parse error.
*
* @param stateNumber the ATN state number
* @param context the full parse context
* @returns The set of potentially valid input symbols which could follow the
* specified state in the specified context.
* @ if the ATN does not contain a state with
* number `stateNumber`
*/
getExpectedTokens(stateNumber, context) {
if (stateNumber < 0 || stateNumber >= this.states.length) {
throw new RangeError("Invalid state number.");
}
let ctx = context;
let s = this.states[stateNumber];
let following = this.nextTokens(s);
if (!following.contains(Token_1.Token.EPSILON)) {
return following;
}
let expected = new IntervalSet_1.IntervalSet();
expected.addAll(following);
expected.remove(Token_1.Token.EPSILON);
while (ctx != null && ctx.invokingState >= 0 && following.contains(Token_1.Token.EPSILON)) {
let invokingState = this.states[ctx.invokingState];
let rt = invokingState.transition(0);
following = this.nextTokens(rt.followState);
expected.addAll(following);
expected.remove(Token_1.Token.EPSILON);
ctx = ctx._parent;
}
if (following.contains(Token_1.Token.EPSILON)) {
expected.add(Token_1.Token.EOF);
}
return expected;
}
};
__decorate([
Decorators_1.NotNull
], ATN.prototype, "states", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "decisionToState", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "modeNameToStartState", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "modeToStartState", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "decisionToDFA", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "modeToDFA", void 0);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "nextTokens", null);
__decorate([
__param(0, Decorators_1.NotNull)
], ATN.prototype, "removeState", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull)
], ATN.prototype, "defineMode", null);
__decorate([
__param(0, Decorators_1.NotNull)
], ATN.prototype, "defineDecisionState", null);
__decorate([
Decorators_1.NotNull
], ATN.prototype, "getExpectedTokens", null);
ATN = __decorate([
__param(0, Decorators_1.NotNull)
], ATN);
exports.ATN = ATN;
(function (ATN) {
ATN.INVALID_ALT_NUMBER = 0;
})(ATN = exports.ATN || (exports.ATN = {}));
exports.ATN = ATN;
//# sourceMappingURL=ATN.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,140 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { Equatable } from "../misc/Stubs";
import { LexerActionExecutor } from "./LexerActionExecutor";
import { PredictionContext } from "./PredictionContext";
import { PredictionContextCache } from "./PredictionContextCache";
import { Recognizer } from "../Recognizer";
import { SemanticContext } from "./SemanticContext";
/**
* Represents a location with context in an ATN. The location is identified by the following values:
*
* * The current ATN state
* * The predicted alternative
* * The semantic context which must be true for this configuration to be enabled
* * The syntactic context, which is represented as a graph-structured stack whose path(s) lead to the root of the rule
* invocations leading to this state
*
* In addition to these values, `ATNConfig` stores several properties about paths taken to get to the location which
* were added over time to help with performance, correctness, and/or debugging.
*
* * `reachesIntoOuterContext`:: Used to ensure semantic predicates are not evaluated in the wrong context.
* * `hasPassedThroughNonGreedyDecision`: Used for enabling first-match-wins instead of longest-match-wins after
* crossing a non-greedy decision.
* * `lexerActionExecutor`: Used for tracking the lexer action(s) to execute should this instance be selected during
* lexing.
* * `isPrecedenceFilterSuppressed`: A state variable for one of the dynamic disambiguation strategies employed by
* `ParserATNSimulator.applyPrecedenceFilter`.
*
* Due to the use of a graph-structured stack, a single `ATNConfig` is capable of representing many individual ATN
* configurations which reached the same location in an ATN by following different paths.
*
* PERF: To conserve memory, `ATNConfig` is split into several different concrete types. `ATNConfig` itself stores the
* minimum amount of information typically used to define an `ATNConfig` instance. Various derived types provide
* additional storage space for cases where a non-default value is used for some of the object properties. The
* `ATNConfig.create` and `ATNConfig.transform` methods automatically select the smallest concrete type capable of
* representing the unique information for any given `ATNConfig`.
*/
export declare class ATNConfig implements Equatable {
/** The ATN state associated with this configuration */
private _state;
/**
* This is a bit-field currently containing the following values.
*
* * 0x00FFFFFF: Alternative
* * 0x7F000000: Outer context depth
* * 0x80000000: Suppress precedence filter
*/
private altAndOuterContextDepth;
/** The stack of invoking states leading to the rule/states associated
* with this config. We track only those contexts pushed during
* execution of the ATN simulator.
*/
private _context;
constructor(/*@NotNull*/ state: ATNState, alt: number, /*@NotNull*/ context: PredictionContext);
constructor(/*@NotNull*/ state: ATNState, /*@NotNull*/ c: ATNConfig, /*@NotNull*/ context: PredictionContext);
static create(/*@NotNull*/ state: ATNState, alt: number, context: PredictionContext): ATNConfig;
static create(/*@NotNull*/ state: ATNState, alt: number, context: PredictionContext, /*@NotNull*/ semanticContext: SemanticContext): ATNConfig;
static create(/*@NotNull*/ state: ATNState, alt: number, context: PredictionContext, /*@*/ semanticContext: SemanticContext, lexerActionExecutor: LexerActionExecutor | undefined): ATNConfig;
/** Gets the ATN state associated with this configuration */
get state(): ATNState;
/** What alt (or lexer rule) is predicted by this configuration */
get alt(): number;
get context(): PredictionContext;
set context(context: PredictionContext);
get reachesIntoOuterContext(): boolean;
/**
* We cannot execute predicates dependent upon local context unless
* we know for sure we are in the correct context. Because there is
* no way to do this efficiently, we simply cannot evaluate
* dependent predicates unless we are in the rule that initially
* invokes the ATN simulator.
*
* closure() tracks the depth of how far we dip into the outer context:
* depth &gt; 0. Note that it may not be totally accurate depth since I
* don't ever decrement. TODO: make it a boolean then
*/
get outerContextDepth(): number;
set outerContextDepth(outerContextDepth: number);
get lexerActionExecutor(): LexerActionExecutor | undefined;
get semanticContext(): SemanticContext;
get hasPassedThroughNonGreedyDecision(): boolean;
clone(): ATNConfig;
transform(/*@NotNull*/ state: ATNState, checkNonGreedy: boolean): ATNConfig;
transform(/*@NotNull*/ state: ATNState, checkNonGreedy: boolean, /*@NotNull*/ semanticContext: SemanticContext): ATNConfig;
transform(/*@NotNull*/ state: ATNState, checkNonGreedy: boolean, context: PredictionContext): ATNConfig;
transform(/*@NotNull*/ state: ATNState, checkNonGreedy: boolean, lexerActionExecutor: LexerActionExecutor): ATNConfig;
private transformImpl;
private static checkNonGreedyDecision;
appendContext(context: number, contextCache: PredictionContextCache): ATNConfig;
appendContext(context: PredictionContext, contextCache: PredictionContextCache): ATNConfig;
/**
* Determines if this `ATNConfig` fully contains another `ATNConfig`.
*
* An ATN configuration represents a position (including context) in an ATN during parsing. Since `ATNConfig` stores
* the context as a graph, a single `ATNConfig` instance is capable of representing many ATN configurations which
* are all in the same "location" but have different contexts. These `ATNConfig` instances are again merged when
* they are added to an `ATNConfigSet`. This method supports `ATNConfigSet.contains` by evaluating whether a
* particular `ATNConfig` contains all of the ATN configurations represented by another `ATNConfig`.
*
* An `ATNConfig` _a_ contains another `ATNConfig` _b_ if all of the following conditions are met:
*
* * The configurations are in the same state (`state`)
* * The configurations predict the same alternative (`alt`)
* * The semantic context of _a_ implies the semantic context of _b_ (this method performs a weaker equality check)
* * Joining the prediction contexts of _a_ and _b_ results in the prediction context of _a_
*
* This method implements a conservative approximation of containment. As a result, when this method returns `true`
* it is known that parsing from `subconfig` can only recognize a subset of the inputs which can be recognized
* starting at the current `ATNConfig`. However, due to the imprecise evaluation of implication for the semantic
* contexts, no assumptions can be made about the relationship between the configurations when this method returns
* `false`.
*
* @param subconfig The sub configuration.
* @returns `true` if this configuration contains `subconfig`; otherwise, `false`.
*/
contains(subconfig: ATNConfig): boolean;
get isPrecedenceFilterSuppressed(): boolean;
set isPrecedenceFilterSuppressed(value: boolean);
/** An ATN configuration is equal to another if both have
* the same state, they predict the same alternative, and
* syntactic/semantic contexts are the same.
*/
equals(o: any): boolean;
hashCode(): number;
/**
* Returns a graphical representation of the current `ATNConfig` in Graphviz format. The graph can be stored to a
* **.dot** file and then rendered to an image using Graphviz.
*
* @returns A Graphviz graph representing the current `ATNConfig`.
*
* @see http://www.graphviz.org/
*/
toDotString(): string;
toString(): string;
toString(recog: Recognizer<any, any> | undefined, showAlt: boolean): string;
toString(recog: Recognizer<any, any> | undefined, showAlt: boolean, showContext: boolean): string;
}

View File

@@ -0,0 +1,524 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNConfig = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:25.2796692-07:00
const Array2DHashMap_1 = require("../misc/Array2DHashMap");
const DecisionState_1 = require("./DecisionState");
const MurmurHash_1 = require("../misc/MurmurHash");
const Decorators_1 = require("../Decorators");
const ObjectEqualityComparator_1 = require("../misc/ObjectEqualityComparator");
const PredictionContext_1 = require("./PredictionContext");
const SemanticContext_1 = require("./SemanticContext");
const assert = require("assert");
/**
* This field stores the bit mask for implementing the
* {@link #isPrecedenceFilterSuppressed} property as a bit within the
* existing {@link #altAndOuterContextDepth} field.
*/
const SUPPRESS_PRECEDENCE_FILTER = 0x80000000;
/**
* Represents a location with context in an ATN. The location is identified by the following values:
*
* * The current ATN state
* * The predicted alternative
* * The semantic context which must be true for this configuration to be enabled
* * The syntactic context, which is represented as a graph-structured stack whose path(s) lead to the root of the rule
* invocations leading to this state
*
* In addition to these values, `ATNConfig` stores several properties about paths taken to get to the location which
* were added over time to help with performance, correctness, and/or debugging.
*
* * `reachesIntoOuterContext`:: Used to ensure semantic predicates are not evaluated in the wrong context.
* * `hasPassedThroughNonGreedyDecision`: Used for enabling first-match-wins instead of longest-match-wins after
* crossing a non-greedy decision.
* * `lexerActionExecutor`: Used for tracking the lexer action(s) to execute should this instance be selected during
* lexing.
* * `isPrecedenceFilterSuppressed`: A state variable for one of the dynamic disambiguation strategies employed by
* `ParserATNSimulator.applyPrecedenceFilter`.
*
* Due to the use of a graph-structured stack, a single `ATNConfig` is capable of representing many individual ATN
* configurations which reached the same location in an ATN by following different paths.
*
* PERF: To conserve memory, `ATNConfig` is split into several different concrete types. `ATNConfig` itself stores the
* minimum amount of information typically used to define an `ATNConfig` instance. Various derived types provide
* additional storage space for cases where a non-default value is used for some of the object properties. The
* `ATNConfig.create` and `ATNConfig.transform` methods automatically select the smallest concrete type capable of
* representing the unique information for any given `ATNConfig`.
*/
let ATNConfig = class ATNConfig {
constructor(state, altOrConfig, context) {
if (typeof altOrConfig === "number") {
assert((altOrConfig & 0xFFFFFF) === altOrConfig);
this._state = state;
this.altAndOuterContextDepth = altOrConfig;
this._context = context;
}
else {
this._state = state;
this.altAndOuterContextDepth = altOrConfig.altAndOuterContextDepth;
this._context = context;
}
}
static create(state, alt, context, semanticContext = SemanticContext_1.SemanticContext.NONE, lexerActionExecutor) {
if (semanticContext !== SemanticContext_1.SemanticContext.NONE) {
if (lexerActionExecutor != null) {
return new ActionSemanticContextATNConfig(lexerActionExecutor, semanticContext, state, alt, context, false);
}
else {
return new SemanticContextATNConfig(semanticContext, state, alt, context);
}
}
else if (lexerActionExecutor != null) {
return new ActionATNConfig(lexerActionExecutor, state, alt, context, false);
}
else {
return new ATNConfig(state, alt, context);
}
}
/** Gets the ATN state associated with this configuration */
get state() {
return this._state;
}
/** What alt (or lexer rule) is predicted by this configuration */
get alt() {
return this.altAndOuterContextDepth & 0x00FFFFFF;
}
get context() {
return this._context;
}
set context(context) {
this._context = context;
}
get reachesIntoOuterContext() {
return this.outerContextDepth !== 0;
}
/**
* We cannot execute predicates dependent upon local context unless
* we know for sure we are in the correct context. Because there is
* no way to do this efficiently, we simply cannot evaluate
* dependent predicates unless we are in the rule that initially
* invokes the ATN simulator.
*
* closure() tracks the depth of how far we dip into the outer context:
* depth &gt; 0. Note that it may not be totally accurate depth since I
* don't ever decrement. TODO: make it a boolean then
*/
get outerContextDepth() {
return (this.altAndOuterContextDepth >>> 24) & 0x7F;
}
set outerContextDepth(outerContextDepth) {
assert(outerContextDepth >= 0);
// saturate at 0x7F - everything but zero/positive is only used for debug information anyway
outerContextDepth = Math.min(outerContextDepth, 0x7F);
this.altAndOuterContextDepth = ((outerContextDepth << 24) | (this.altAndOuterContextDepth & ~0x7F000000) >>> 0);
}
get lexerActionExecutor() {
return undefined;
}
get semanticContext() {
return SemanticContext_1.SemanticContext.NONE;
}
get hasPassedThroughNonGreedyDecision() {
return false;
}
clone() {
return this.transform(this.state, false);
}
transform(/*@NotNull*/ state, checkNonGreedy, arg2) {
if (arg2 == null) {
return this.transformImpl(state, this._context, this.semanticContext, checkNonGreedy, this.lexerActionExecutor);
}
else if (arg2 instanceof PredictionContext_1.PredictionContext) {
return this.transformImpl(state, arg2, this.semanticContext, checkNonGreedy, this.lexerActionExecutor);
}
else if (arg2 instanceof SemanticContext_1.SemanticContext) {
return this.transformImpl(state, this._context, arg2, checkNonGreedy, this.lexerActionExecutor);
}
else {
return this.transformImpl(state, this._context, this.semanticContext, checkNonGreedy, arg2);
}
}
transformImpl(state, context, semanticContext, checkNonGreedy, lexerActionExecutor) {
let passedThroughNonGreedy = checkNonGreedy && ATNConfig.checkNonGreedyDecision(this, state);
if (semanticContext !== SemanticContext_1.SemanticContext.NONE) {
if (lexerActionExecutor != null || passedThroughNonGreedy) {
return new ActionSemanticContextATNConfig(lexerActionExecutor, semanticContext, state, this, context, passedThroughNonGreedy);
}
else {
return new SemanticContextATNConfig(semanticContext, state, this, context);
}
}
else if (lexerActionExecutor != null || passedThroughNonGreedy) {
return new ActionATNConfig(lexerActionExecutor, state, this, context, passedThroughNonGreedy);
}
else {
return new ATNConfig(state, this, context);
}
}
static checkNonGreedyDecision(source, target) {
return source.hasPassedThroughNonGreedyDecision
|| target instanceof DecisionState_1.DecisionState && target.nonGreedy;
}
appendContext(context, contextCache) {
if (typeof context === "number") {
let appendedContext = this.context.appendSingleContext(context, contextCache);
let result = this.transform(this.state, false, appendedContext);
return result;
}
else {
let appendedContext = this.context.appendContext(context, contextCache);
let result = this.transform(this.state, false, appendedContext);
return result;
}
}
/**
* Determines if this `ATNConfig` fully contains another `ATNConfig`.
*
* An ATN configuration represents a position (including context) in an ATN during parsing. Since `ATNConfig` stores
* the context as a graph, a single `ATNConfig` instance is capable of representing many ATN configurations which
* are all in the same "location" but have different contexts. These `ATNConfig` instances are again merged when
* they are added to an `ATNConfigSet`. This method supports `ATNConfigSet.contains` by evaluating whether a
* particular `ATNConfig` contains all of the ATN configurations represented by another `ATNConfig`.
*
* An `ATNConfig` _a_ contains another `ATNConfig` _b_ if all of the following conditions are met:
*
* * The configurations are in the same state (`state`)
* * The configurations predict the same alternative (`alt`)
* * The semantic context of _a_ implies the semantic context of _b_ (this method performs a weaker equality check)
* * Joining the prediction contexts of _a_ and _b_ results in the prediction context of _a_
*
* This method implements a conservative approximation of containment. As a result, when this method returns `true`
* it is known that parsing from `subconfig` can only recognize a subset of the inputs which can be recognized
* starting at the current `ATNConfig`. However, due to the imprecise evaluation of implication for the semantic
* contexts, no assumptions can be made about the relationship between the configurations when this method returns
* `false`.
*
* @param subconfig The sub configuration.
* @returns `true` if this configuration contains `subconfig`; otherwise, `false`.
*/
contains(subconfig) {
if (this.state.stateNumber !== subconfig.state.stateNumber
|| this.alt !== subconfig.alt
|| !this.semanticContext.equals(subconfig.semanticContext)) {
return false;
}
let leftWorkList = [];
let rightWorkList = [];
leftWorkList.push(this.context);
rightWorkList.push(subconfig.context);
while (true) {
let left = leftWorkList.pop();
let right = rightWorkList.pop();
if (!left || !right) {
break;
}
if (left === right) {
return true;
}
if (left.size < right.size) {
return false;
}
if (right.isEmpty) {
return left.hasEmpty;
}
else {
for (let i = 0; i < right.size; i++) {
let index = left.findReturnState(right.getReturnState(i));
if (index < 0) {
// assumes invokingStates has no duplicate entries
return false;
}
leftWorkList.push(left.getParent(index));
rightWorkList.push(right.getParent(i));
}
}
}
return false;
}
get isPrecedenceFilterSuppressed() {
return (this.altAndOuterContextDepth & SUPPRESS_PRECEDENCE_FILTER) !== 0;
}
set isPrecedenceFilterSuppressed(value) {
if (value) {
this.altAndOuterContextDepth |= SUPPRESS_PRECEDENCE_FILTER;
}
else {
this.altAndOuterContextDepth &= ~SUPPRESS_PRECEDENCE_FILTER;
}
}
/** An ATN configuration is equal to another if both have
* the same state, they predict the same alternative, and
* syntactic/semantic contexts are the same.
*/
equals(o) {
if (this === o) {
return true;
}
else if (!(o instanceof ATNConfig)) {
return false;
}
return this.state.stateNumber === o.state.stateNumber
&& this.alt === o.alt
&& this.reachesIntoOuterContext === o.reachesIntoOuterContext
&& this.context.equals(o.context)
&& this.semanticContext.equals(o.semanticContext)
&& this.isPrecedenceFilterSuppressed === o.isPrecedenceFilterSuppressed
&& this.hasPassedThroughNonGreedyDecision === o.hasPassedThroughNonGreedyDecision
&& ObjectEqualityComparator_1.ObjectEqualityComparator.INSTANCE.equals(this.lexerActionExecutor, o.lexerActionExecutor);
}
hashCode() {
let hashCode = MurmurHash_1.MurmurHash.initialize(7);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.state.stateNumber);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.alt);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.reachesIntoOuterContext ? 1 : 0);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.context);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.semanticContext);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.hasPassedThroughNonGreedyDecision ? 1 : 0);
hashCode = MurmurHash_1.MurmurHash.update(hashCode, this.lexerActionExecutor);
hashCode = MurmurHash_1.MurmurHash.finish(hashCode, 7);
return hashCode;
}
/**
* Returns a graphical representation of the current `ATNConfig` in Graphviz format. The graph can be stored to a
* **.dot** file and then rendered to an image using Graphviz.
*
* @returns A Graphviz graph representing the current `ATNConfig`.
*
* @see http://www.graphviz.org/
*/
toDotString() {
let builder = "";
builder += ("digraph G {\n");
builder += ("rankdir=LR;\n");
let visited = new Array2DHashMap_1.Array2DHashMap(PredictionContext_1.PredictionContext.IdentityEqualityComparator.INSTANCE);
let workList = [];
function getOrAddContext(context) {
let newNumber = visited.size;
let result = visited.putIfAbsent(context, newNumber);
if (result != null) {
// Already saw this context
return result;
}
workList.push(context);
return newNumber;
}
workList.push(this.context);
visited.put(this.context, 0);
while (true) {
let current = workList.pop();
if (!current) {
break;
}
for (let i = 0; i < current.size; i++) {
builder += (" s") + (getOrAddContext(current));
builder += ("->");
builder += ("s") + (getOrAddContext(current.getParent(i)));
builder += ("[label=\"") + (current.getReturnState(i)) + ("\"];\n");
}
}
builder += ("}\n");
return builder.toString();
}
toString(recog, showAlt, showContext) {
// Must check showContext before showAlt to preserve original overload behavior
if (showContext == null) {
showContext = showAlt != null;
}
if (showAlt == null) {
showAlt = true;
}
let buf = "";
// if (this.state.ruleIndex >= 0) {
// if (recog != null) {
// buf += (recog.ruleNames[this.state.ruleIndex] + ":");
// } else {
// buf += (this.state.ruleIndex + ":");
// }
// }
let contexts;
if (showContext) {
contexts = this.context.toStrings(recog, this.state.stateNumber);
}
else {
contexts = ["?"];
}
let first = true;
for (let contextDesc of contexts) {
if (first) {
first = false;
}
else {
buf += (", ");
}
buf += ("(");
buf += (this.state);
if (showAlt) {
buf += (",");
buf += (this.alt);
}
if (this.context) {
buf += (",");
buf += (contextDesc);
}
if (this.semanticContext !== SemanticContext_1.SemanticContext.NONE) {
buf += (",");
buf += (this.semanticContext);
}
if (this.reachesIntoOuterContext) {
buf += (",up=") + (this.outerContextDepth);
}
buf += (")");
}
return buf.toString();
}
};
__decorate([
Decorators_1.NotNull
], ATNConfig.prototype, "_state", void 0);
__decorate([
Decorators_1.NotNull
], ATNConfig.prototype, "_context", void 0);
__decorate([
Decorators_1.NotNull
], ATNConfig.prototype, "state", null);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull)
], ATNConfig.prototype, "context", null);
__decorate([
Decorators_1.NotNull
], ATNConfig.prototype, "semanticContext", null);
__decorate([
Decorators_1.Override
], ATNConfig.prototype, "clone", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], ATNConfig.prototype, "transformImpl", null);
__decorate([
Decorators_1.Override
], ATNConfig.prototype, "equals", null);
__decorate([
Decorators_1.Override
], ATNConfig.prototype, "hashCode", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(3, Decorators_1.NotNull)
], ATNConfig, "create", null);
ATNConfig = __decorate([
__param(0, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], ATNConfig);
exports.ATNConfig = ATNConfig;
/**
* This class was derived from `ATNConfig` purely as a memory optimization. It allows for the creation of an `ATNConfig`
* with a non-default semantic context.
*
* See the `ATNConfig` documentation for more information about conserving memory through the use of several concrete
* types.
*/
let SemanticContextATNConfig = class SemanticContextATNConfig extends ATNConfig {
constructor(semanticContext, state, altOrConfig, context) {
if (typeof altOrConfig === "number") {
super(state, altOrConfig, context);
}
else {
super(state, altOrConfig, context);
}
this._semanticContext = semanticContext;
}
get semanticContext() {
return this._semanticContext;
}
};
__decorate([
Decorators_1.NotNull
], SemanticContextATNConfig.prototype, "_semanticContext", void 0);
__decorate([
Decorators_1.Override
], SemanticContextATNConfig.prototype, "semanticContext", null);
SemanticContextATNConfig = __decorate([
__param(1, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], SemanticContextATNConfig);
/**
* This class was derived from `ATNConfig` purely as a memory optimization. It allows for the creation of an `ATNConfig`
* with a lexer action.
*
* See the `ATNConfig` documentation for more information about conserving memory through the use of several concrete
* types.
*/
let ActionATNConfig = class ActionATNConfig extends ATNConfig {
constructor(lexerActionExecutor, state, altOrConfig, context, passedThroughNonGreedyDecision) {
if (typeof altOrConfig === "number") {
super(state, altOrConfig, context);
}
else {
super(state, altOrConfig, context);
if (altOrConfig.semanticContext !== SemanticContext_1.SemanticContext.NONE) {
throw new Error("Not supported");
}
}
this._lexerActionExecutor = lexerActionExecutor;
this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision;
}
get lexerActionExecutor() {
return this._lexerActionExecutor;
}
get hasPassedThroughNonGreedyDecision() {
return this.passedThroughNonGreedyDecision;
}
};
__decorate([
Decorators_1.Override
], ActionATNConfig.prototype, "lexerActionExecutor", null);
__decorate([
Decorators_1.Override
], ActionATNConfig.prototype, "hasPassedThroughNonGreedyDecision", null);
ActionATNConfig = __decorate([
__param(1, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], ActionATNConfig);
/**
* This class was derived from `SemanticContextATNConfig` purely as a memory optimization. It allows for the creation of
* an `ATNConfig` with both a lexer action and a non-default semantic context.
*
* See the `ATNConfig` documentation for more information about conserving memory through the use of several concrete
* types.
*/
let ActionSemanticContextATNConfig = class ActionSemanticContextATNConfig extends SemanticContextATNConfig {
constructor(lexerActionExecutor, semanticContext, state, altOrConfig, context, passedThroughNonGreedyDecision) {
if (typeof altOrConfig === "number") {
super(semanticContext, state, altOrConfig, context);
}
else {
super(semanticContext, state, altOrConfig, context);
}
this._lexerActionExecutor = lexerActionExecutor;
this.passedThroughNonGreedyDecision = passedThroughNonGreedyDecision;
}
get lexerActionExecutor() {
return this._lexerActionExecutor;
}
get hasPassedThroughNonGreedyDecision() {
return this.passedThroughNonGreedyDecision;
}
};
__decorate([
Decorators_1.Override
], ActionSemanticContextATNConfig.prototype, "lexerActionExecutor", null);
__decorate([
Decorators_1.Override
], ActionSemanticContextATNConfig.prototype, "hasPassedThroughNonGreedyDecision", null);
ActionSemanticContextATNConfig = __decorate([
__param(1, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], ActionSemanticContextATNConfig);
//# sourceMappingURL=ATNConfig.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Array2DHashSet } from "../misc/Array2DHashSet";
import { ATNConfig } from "./ATNConfig";
import { ATNSimulator } from "./ATNSimulator";
import { ATNState } from "./ATNState";
import { BitSet } from "../misc/BitSet";
import { ConflictInfo } from "./ConflictInfo";
import { JavaSet } from "../misc/Stubs";
import { PredictionContextCache } from "./PredictionContextCache";
/**
* Represents a set of ATN configurations (see `ATNConfig`). As configurations are added to the set, they are merged
* with other `ATNConfig` instances already in the set when possible using the graph-structured stack.
*
* An instance of this class represents the complete set of positions (with context) in an ATN which would be associated
* with a single DFA state. Its internal representation is more complex than traditional state used for NFA to DFA
* conversion due to performance requirements (both improving speed and reducing memory overhead) as well as supporting
* features such as semantic predicates and non-greedy operators in a form to support ANTLR's prediction algorithm.
*
* @author Sam Harwell
*/
export declare class ATNConfigSet implements JavaSet<ATNConfig> {
/**
* This maps (state, alt) -> merged {@link ATNConfig}. The key does not account for
* the {@link ATNConfig#getSemanticContext} of the value, which is only a problem if a single
* `ATNConfigSet` contains two configs with the same state and alternative
* but different semantic contexts. When this case arises, the first config
* added to this map stays, and the remaining configs are placed in {@link #unmerged}.
*
* This map is only used for optimizing the process of adding configs to the set,
* and is `undefined` for read-only sets stored in the DFA.
*/
private mergedConfigs?;
/**
* This is an "overflow" list holding configs which cannot be merged with one
* of the configs in {@link #mergedConfigs} but have a colliding key. This
* occurs when two configs in the set have the same state and alternative but
* different semantic contexts.
*
* This list is only used for optimizing the process of adding configs to the set,
* and is `undefined` for read-only sets stored in the DFA.
*/
private unmerged?;
/**
* This is a list of all configs in this set.
*/
private configs;
private _uniqueAlt;
private _conflictInfo?;
private _hasSemanticContext;
private _dipsIntoOuterContext;
/**
* When `true`, this config set represents configurations where the entire
* outer context has been consumed by the ATN interpreter. This prevents the
* {@link ParserATNSimulator#closure} from pursuing the global FOLLOW when a
* rule stop state is reached with an empty prediction context.
*
* Note: `outermostConfigSet` and {@link #dipsIntoOuterContext} should never
* be true at the same time.
*/
private outermostConfigSet;
private cachedHashCode;
constructor();
constructor(set: ATNConfigSet, readonly: boolean);
/**
* Get the set of all alternatives represented by configurations in this
* set.
*/
getRepresentedAlternatives(): BitSet;
get isReadOnly(): boolean;
get isOutermostConfigSet(): boolean;
set isOutermostConfigSet(outermostConfigSet: boolean);
getStates(): Array2DHashSet<ATNState>;
optimizeConfigs(interpreter: ATNSimulator): void;
clone(readonly: boolean): ATNConfigSet;
get size(): number;
get isEmpty(): boolean;
contains(o: any): boolean;
[Symbol.iterator](): IterableIterator<ATNConfig>;
toArray(): ATNConfig[];
add(e: ATNConfig): boolean;
add(e: ATNConfig, contextCache: PredictionContextCache | undefined): boolean;
private updatePropertiesForMergedConfig;
private updatePropertiesForAddedConfig;
protected canMerge(left: ATNConfig, leftKey: {
state: number;
alt: number;
}, right: ATNConfig): boolean;
protected getKey(e: ATNConfig): {
state: number;
alt: number;
};
containsAll(c: Iterable<any>): boolean;
addAll(c: Iterable<ATNConfig>): boolean;
addAll(c: Iterable<ATNConfig>, contextCache: PredictionContextCache): boolean;
clear(): void;
equals(obj: any): boolean;
hashCode(): number;
toString(): string;
toString(showContext: boolean): string;
get uniqueAlt(): number;
get hasSemanticContext(): boolean;
set hasSemanticContext(value: boolean);
get conflictInfo(): ConflictInfo | undefined;
set conflictInfo(conflictInfo: ConflictInfo | undefined);
get conflictingAlts(): BitSet | undefined;
get isExactConflict(): boolean;
get dipsIntoOuterContext(): boolean;
get(index: number): ATNConfig;
protected ensureWritable(): void;
}

View File

@@ -0,0 +1,446 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNConfigSet = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:25.5488013-07:00
const Array2DHashMap_1 = require("../misc/Array2DHashMap");
const Array2DHashSet_1 = require("../misc/Array2DHashSet");
const ArrayEqualityComparator_1 = require("../misc/ArrayEqualityComparator");
const ATN_1 = require("./ATN");
const ATNConfig_1 = require("./ATNConfig");
const BitSet_1 = require("../misc/BitSet");
const Decorators_1 = require("../Decorators");
const ObjectEqualityComparator_1 = require("../misc/ObjectEqualityComparator");
const PredictionContext_1 = require("./PredictionContext");
const PredictionContextCache_1 = require("./PredictionContextCache");
const SemanticContext_1 = require("./SemanticContext");
const assert = require("assert");
const Utils = require("../misc/Utils");
class KeyTypeEqualityComparer {
hashCode(key) {
return key.state ^ key.alt;
}
equals(a, b) {
return a.state === b.state && a.alt === b.alt;
}
}
KeyTypeEqualityComparer.INSTANCE = new KeyTypeEqualityComparer();
function NewKeyedConfigMap(map) {
if (map) {
return new Array2DHashMap_1.Array2DHashMap(map);
}
else {
return new Array2DHashMap_1.Array2DHashMap(KeyTypeEqualityComparer.INSTANCE);
}
}
/**
* Represents a set of ATN configurations (see `ATNConfig`). As configurations are added to the set, they are merged
* with other `ATNConfig` instances already in the set when possible using the graph-structured stack.
*
* An instance of this class represents the complete set of positions (with context) in an ATN which would be associated
* with a single DFA state. Its internal representation is more complex than traditional state used for NFA to DFA
* conversion due to performance requirements (both improving speed and reducing memory overhead) as well as supporting
* features such as semantic predicates and non-greedy operators in a form to support ANTLR's prediction algorithm.
*
* @author Sam Harwell
*/
class ATNConfigSet {
constructor(set, readonly) {
this._uniqueAlt = 0;
// Used in parser and lexer. In lexer, it indicates we hit a pred
// while computing a closure operation. Don't make a DFA state from this.
this._hasSemanticContext = false;
this._dipsIntoOuterContext = false;
/**
* When `true`, this config set represents configurations where the entire
* outer context has been consumed by the ATN interpreter. This prevents the
* {@link ParserATNSimulator#closure} from pursuing the global FOLLOW when a
* rule stop state is reached with an empty prediction context.
*
* Note: `outermostConfigSet` and {@link #dipsIntoOuterContext} should never
* be true at the same time.
*/
this.outermostConfigSet = false;
this.cachedHashCode = -1;
if (!set) {
this.mergedConfigs = NewKeyedConfigMap();
this.unmerged = [];
this.configs = [];
this._uniqueAlt = ATN_1.ATN.INVALID_ALT_NUMBER;
}
else {
if (readonly) {
this.mergedConfigs = undefined;
this.unmerged = undefined;
}
else if (!set.isReadOnly) {
this.mergedConfigs = NewKeyedConfigMap(set.mergedConfigs);
this.unmerged = set.unmerged.slice(0);
}
else {
this.mergedConfigs = NewKeyedConfigMap();
this.unmerged = [];
}
this.configs = set.configs.slice(0);
this._dipsIntoOuterContext = set._dipsIntoOuterContext;
this._hasSemanticContext = set._hasSemanticContext;
this.outermostConfigSet = set.outermostConfigSet;
if (readonly || !set.isReadOnly) {
this._uniqueAlt = set._uniqueAlt;
this._conflictInfo = set._conflictInfo;
}
// if (!readonly && set.isReadOnly) -> addAll is called from clone()
}
}
/**
* Get the set of all alternatives represented by configurations in this
* set.
*/
getRepresentedAlternatives() {
if (this._conflictInfo != null) {
return this._conflictInfo.conflictedAlts.clone();
}
let alts = new BitSet_1.BitSet();
for (let config of this) {
alts.set(config.alt);
}
return alts;
}
get isReadOnly() {
return this.mergedConfigs == null;
}
get isOutermostConfigSet() {
return this.outermostConfigSet;
}
set isOutermostConfigSet(outermostConfigSet) {
if (this.outermostConfigSet && !outermostConfigSet) {
throw new Error("IllegalStateException");
}
assert(!outermostConfigSet || !this._dipsIntoOuterContext);
this.outermostConfigSet = outermostConfigSet;
}
getStates() {
let states = new Array2DHashSet_1.Array2DHashSet(ObjectEqualityComparator_1.ObjectEqualityComparator.INSTANCE);
for (let c of this.configs) {
states.add(c.state);
}
return states;
}
optimizeConfigs(interpreter) {
if (this.configs.length === 0) {
return;
}
for (let config of this.configs) {
config.context = interpreter.atn.getCachedContext(config.context);
}
}
clone(readonly) {
let copy = new ATNConfigSet(this, readonly);
if (!readonly && this.isReadOnly) {
copy.addAll(this.configs);
}
return copy;
}
get size() {
return this.configs.length;
}
get isEmpty() {
return this.configs.length === 0;
}
contains(o) {
if (!(o instanceof ATNConfig_1.ATNConfig)) {
return false;
}
if (this.mergedConfigs && this.unmerged) {
let config = o;
let configKey = this.getKey(config);
let mergedConfig = this.mergedConfigs.get(configKey);
if (mergedConfig != null && this.canMerge(config, configKey, mergedConfig)) {
return mergedConfig.contains(config);
}
for (let c of this.unmerged) {
if (c.contains(o)) {
return true;
}
}
}
else {
for (let c of this.configs) {
if (c.contains(o)) {
return true;
}
}
}
return false;
}
*[Symbol.iterator]() {
yield* this.configs;
}
toArray() {
return this.configs;
}
add(e, contextCache) {
this.ensureWritable();
if (!this.mergedConfigs || !this.unmerged) {
throw new Error("Covered by ensureWritable but duplicated here for strict null check limitation");
}
assert(!this.outermostConfigSet || !e.reachesIntoOuterContext);
if (contextCache == null) {
contextCache = PredictionContextCache_1.PredictionContextCache.UNCACHED;
}
let addKey;
let key = this.getKey(e);
let mergedConfig = this.mergedConfigs.get(key);
addKey = (mergedConfig == null);
if (mergedConfig != null && this.canMerge(e, key, mergedConfig)) {
mergedConfig.outerContextDepth = Math.max(mergedConfig.outerContextDepth, e.outerContextDepth);
if (e.isPrecedenceFilterSuppressed) {
mergedConfig.isPrecedenceFilterSuppressed = true;
}
let joined = PredictionContext_1.PredictionContext.join(mergedConfig.context, e.context, contextCache);
this.updatePropertiesForMergedConfig(e);
if (mergedConfig.context === joined) {
return false;
}
mergedConfig.context = joined;
return true;
}
for (let i = 0; i < this.unmerged.length; i++) {
let unmergedConfig = this.unmerged[i];
if (this.canMerge(e, key, unmergedConfig)) {
unmergedConfig.outerContextDepth = Math.max(unmergedConfig.outerContextDepth, e.outerContextDepth);
if (e.isPrecedenceFilterSuppressed) {
unmergedConfig.isPrecedenceFilterSuppressed = true;
}
let joined = PredictionContext_1.PredictionContext.join(unmergedConfig.context, e.context, contextCache);
this.updatePropertiesForMergedConfig(e);
if (unmergedConfig.context === joined) {
return false;
}
unmergedConfig.context = joined;
if (addKey) {
this.mergedConfigs.put(key, unmergedConfig);
this.unmerged.splice(i, 1);
}
return true;
}
}
this.configs.push(e);
if (addKey) {
this.mergedConfigs.put(key, e);
}
else {
this.unmerged.push(e);
}
this.updatePropertiesForAddedConfig(e);
return true;
}
updatePropertiesForMergedConfig(config) {
// merged configs can't change the alt or semantic context
this._dipsIntoOuterContext = this._dipsIntoOuterContext || config.reachesIntoOuterContext;
assert(!this.outermostConfigSet || !this._dipsIntoOuterContext);
}
updatePropertiesForAddedConfig(config) {
if (this.configs.length === 1) {
this._uniqueAlt = config.alt;
}
else if (this._uniqueAlt !== config.alt) {
this._uniqueAlt = ATN_1.ATN.INVALID_ALT_NUMBER;
}
this._hasSemanticContext = this._hasSemanticContext || !SemanticContext_1.SemanticContext.NONE.equals(config.semanticContext);
this._dipsIntoOuterContext = this._dipsIntoOuterContext || config.reachesIntoOuterContext;
assert(!this.outermostConfigSet || !this._dipsIntoOuterContext);
}
canMerge(left, leftKey, right) {
if (left.state.stateNumber !== right.state.stateNumber) {
return false;
}
if (leftKey.alt !== right.alt) {
return false;
}
return left.semanticContext.equals(right.semanticContext);
}
getKey(e) {
return { state: e.state.stateNumber, alt: e.alt };
}
containsAll(c) {
for (let o of c) {
if (!(o instanceof ATNConfig_1.ATNConfig)) {
return false;
}
if (!this.contains(o)) {
return false;
}
}
return true;
}
addAll(c, contextCache) {
this.ensureWritable();
let changed = false;
for (let group of c) {
if (this.add(group, contextCache)) {
changed = true;
}
}
return changed;
}
clear() {
this.ensureWritable();
if (!this.mergedConfigs || !this.unmerged) {
throw new Error("Covered by ensureWritable but duplicated here for strict null check limitation");
}
this.mergedConfigs.clear();
this.unmerged.length = 0;
this.configs.length = 0;
this._dipsIntoOuterContext = false;
this._hasSemanticContext = false;
this._uniqueAlt = ATN_1.ATN.INVALID_ALT_NUMBER;
this._conflictInfo = undefined;
}
equals(obj) {
if (this === obj) {
return true;
}
if (!(obj instanceof ATNConfigSet)) {
return false;
}
return this.outermostConfigSet === obj.outermostConfigSet
&& Utils.equals(this._conflictInfo, obj._conflictInfo)
&& ArrayEqualityComparator_1.ArrayEqualityComparator.INSTANCE.equals(this.configs, obj.configs);
}
hashCode() {
if (this.isReadOnly && this.cachedHashCode !== -1) {
return this.cachedHashCode;
}
let hashCode = 1;
hashCode = 5 * hashCode ^ (this.outermostConfigSet ? 1 : 0);
hashCode = 5 * hashCode ^ ArrayEqualityComparator_1.ArrayEqualityComparator.INSTANCE.hashCode(this.configs);
if (this.isReadOnly) {
this.cachedHashCode = hashCode;
}
return hashCode;
}
toString(showContext) {
if (showContext == null) {
showContext = false;
}
let buf = "";
let sortedConfigs = this.configs.slice(0);
sortedConfigs.sort((o1, o2) => {
if (o1.alt !== o2.alt) {
return o1.alt - o2.alt;
}
else if (o1.state.stateNumber !== o2.state.stateNumber) {
return o1.state.stateNumber - o2.state.stateNumber;
}
else {
return o1.semanticContext.toString().localeCompare(o2.semanticContext.toString());
}
});
buf += ("[");
for (let i = 0; i < sortedConfigs.length; i++) {
if (i > 0) {
buf += (", ");
}
buf += (sortedConfigs[i].toString(undefined, true, showContext));
}
buf += ("]");
if (this._hasSemanticContext) {
buf += (",hasSemanticContext=") + (this._hasSemanticContext);
}
if (this._uniqueAlt !== ATN_1.ATN.INVALID_ALT_NUMBER) {
buf += (",uniqueAlt=") + (this._uniqueAlt);
}
if (this._conflictInfo != null) {
buf += (",conflictingAlts=") + (this._conflictInfo.conflictedAlts);
if (!this._conflictInfo.isExact) {
buf += ("*");
}
}
if (this._dipsIntoOuterContext) {
buf += (",dipsIntoOuterContext");
}
return buf.toString();
}
get uniqueAlt() {
return this._uniqueAlt;
}
get hasSemanticContext() {
return this._hasSemanticContext;
}
set hasSemanticContext(value) {
this.ensureWritable();
this._hasSemanticContext = value;
}
get conflictInfo() {
return this._conflictInfo;
}
set conflictInfo(conflictInfo) {
this.ensureWritable();
this._conflictInfo = conflictInfo;
}
get conflictingAlts() {
if (this._conflictInfo == null) {
return undefined;
}
return this._conflictInfo.conflictedAlts;
}
get isExactConflict() {
if (this._conflictInfo == null) {
return false;
}
return this._conflictInfo.isExact;
}
get dipsIntoOuterContext() {
return this._dipsIntoOuterContext;
}
get(index) {
return this.configs[index];
}
ensureWritable() {
if (this.isReadOnly) {
throw new Error("This ATNConfigSet is read only.");
}
}
}
__decorate([
Decorators_1.NotNull
], ATNConfigSet.prototype, "getRepresentedAlternatives", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "size", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "isEmpty", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "contains", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, Symbol.iterator, null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "toArray", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "containsAll", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "clear", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "equals", null);
__decorate([
Decorators_1.Override
], ATNConfigSet.prototype, "hashCode", null);
exports.ATNConfigSet = ATNConfigSet;
//# sourceMappingURL=ATNConfigSet.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
/**
*
* @author Sam Harwell
*/
export declare class ATNDeserializationOptions {
private static _defaultOptions?;
private readOnly;
private verifyATN;
private generateRuleBypassTransitions;
private optimize;
constructor(options?: ATNDeserializationOptions);
static get defaultOptions(): ATNDeserializationOptions;
get isReadOnly(): boolean;
makeReadOnly(): void;
get isVerifyATN(): boolean;
set isVerifyATN(verifyATN: boolean);
get isGenerateRuleBypassTransitions(): boolean;
set isGenerateRuleBypassTransitions(generateRuleBypassTransitions: boolean);
get isOptimize(): boolean;
set isOptimize(optimize: boolean);
protected throwIfReadOnly(): void;
}

View File

@@ -0,0 +1,78 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNDeserializationOptions = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:25.8187912-07:00
const Decorators_1 = require("../Decorators");
/**
*
* @author Sam Harwell
*/
class ATNDeserializationOptions {
constructor(options) {
this.readOnly = false;
if (options) {
this.verifyATN = options.verifyATN;
this.generateRuleBypassTransitions = options.generateRuleBypassTransitions;
this.optimize = options.optimize;
}
else {
this.verifyATN = true;
this.generateRuleBypassTransitions = false;
this.optimize = true;
}
}
static get defaultOptions() {
if (ATNDeserializationOptions._defaultOptions == null) {
ATNDeserializationOptions._defaultOptions = new ATNDeserializationOptions();
ATNDeserializationOptions._defaultOptions.makeReadOnly();
}
return ATNDeserializationOptions._defaultOptions;
}
get isReadOnly() {
return this.readOnly;
}
makeReadOnly() {
this.readOnly = true;
}
get isVerifyATN() {
return this.verifyATN;
}
set isVerifyATN(verifyATN) {
this.throwIfReadOnly();
this.verifyATN = verifyATN;
}
get isGenerateRuleBypassTransitions() {
return this.generateRuleBypassTransitions;
}
set isGenerateRuleBypassTransitions(generateRuleBypassTransitions) {
this.throwIfReadOnly();
this.generateRuleBypassTransitions = generateRuleBypassTransitions;
}
get isOptimize() {
return this.optimize;
}
set isOptimize(optimize) {
this.throwIfReadOnly();
this.optimize = optimize;
}
throwIfReadOnly() {
if (this.isReadOnly) {
throw new Error("The object is read only.");
}
}
}
__decorate([
Decorators_1.NotNull
], ATNDeserializationOptions, "defaultOptions", null);
exports.ATNDeserializationOptions = ATNDeserializationOptions;
//# sourceMappingURL=ATNDeserializationOptions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ATNDeserializationOptions.js","sourceRoot":"","sources":["../../../src/atn/ATNDeserializationOptions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,wDAAwD;AAExD,8CAAwC;AAExC;;;GAGG;AACH,MAAa,yBAAyB;IAQrC,YAAY,OAAmC;QALvC,aAAQ,GAAY,KAAK,CAAC;QAMjC,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YACnC,IAAI,CAAC,6BAA6B,GAAG,OAAO,CAAC,6BAA6B,CAAC;YAC3E,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;SACjC;aAAM;YACN,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,6BAA6B,GAAG,KAAK,CAAC;YAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACrB;IACF,CAAC;IAGD,MAAM,KAAK,cAAc;QACxB,IAAI,yBAAyB,CAAC,eAAe,IAAI,IAAI,EAAE;YACtD,yBAAyB,CAAC,eAAe,GAAG,IAAI,yBAAyB,EAAE,CAAC;YAC5E,yBAAyB,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC;SACzD;QAED,OAAO,yBAAyB,CAAC,eAAe,CAAC;IAClD,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,WAAW,CAAC,SAAkB;QACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,IAAI,+BAA+B;QAClC,OAAO,IAAI,CAAC,6BAA6B,CAAC;IAC3C,CAAC;IAED,IAAI,+BAA+B,CAAC,6BAAsC;QACzE,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;IACpE,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,UAAU,CAAC,QAAiB;QAC/B,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAES,eAAe;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC5C;IACF,CAAC;CACD;AAjDA;IADC,oBAAO;qDAQP;AA5BF,8DAsEC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:25.8187912-07:00\r\n\r\nimport { NotNull } from \"../Decorators\";\r\n\r\n/**\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport class ATNDeserializationOptions {\r\n\tprivate static _defaultOptions?: ATNDeserializationOptions;\r\n\r\n\tprivate readOnly: boolean = false;\r\n\tprivate verifyATN: boolean;\r\n\tprivate generateRuleBypassTransitions: boolean;\r\n\tprivate optimize: boolean;\r\n\r\n\tconstructor(options?: ATNDeserializationOptions) {\r\n\t\tif (options) {\r\n\t\t\tthis.verifyATN = options.verifyATN;\r\n\t\t\tthis.generateRuleBypassTransitions = options.generateRuleBypassTransitions;\r\n\t\t\tthis.optimize = options.optimize;\r\n\t\t} else {\r\n\t\t\tthis.verifyATN = true;\r\n\t\t\tthis.generateRuleBypassTransitions = false;\r\n\t\t\tthis.optimize = true;\r\n\t\t}\r\n\t}\r\n\r\n\t@NotNull\r\n\tstatic get defaultOptions(): ATNDeserializationOptions {\r\n\t\tif (ATNDeserializationOptions._defaultOptions == null) {\r\n\t\t\tATNDeserializationOptions._defaultOptions = new ATNDeserializationOptions();\r\n\t\t\tATNDeserializationOptions._defaultOptions.makeReadOnly();\r\n\t\t}\r\n\r\n\t\treturn ATNDeserializationOptions._defaultOptions;\r\n\t}\r\n\r\n\tget isReadOnly(): boolean {\r\n\t\treturn this.readOnly;\r\n\t}\r\n\r\n\tpublic makeReadOnly(): void {\r\n\t\tthis.readOnly = true;\r\n\t}\r\n\r\n\tget isVerifyATN(): boolean {\r\n\t\treturn this.verifyATN;\r\n\t}\r\n\r\n\tset isVerifyATN(verifyATN: boolean) {\r\n\t\tthis.throwIfReadOnly();\r\n\t\tthis.verifyATN = verifyATN;\r\n\t}\r\n\r\n\tget isGenerateRuleBypassTransitions(): boolean {\r\n\t\treturn this.generateRuleBypassTransitions;\r\n\t}\r\n\r\n\tset isGenerateRuleBypassTransitions(generateRuleBypassTransitions: boolean) {\r\n\t\tthis.throwIfReadOnly();\r\n\t\tthis.generateRuleBypassTransitions = generateRuleBypassTransitions;\r\n\t}\r\n\r\n\tget isOptimize(): boolean {\r\n\t\treturn this.optimize;\r\n\t}\r\n\r\n\tset isOptimize(optimize: boolean) {\r\n\t\tthis.throwIfReadOnly();\r\n\t\tthis.optimize = optimize;\r\n\t}\r\n\r\n\tprotected throwIfReadOnly(): void {\r\n\t\tif (this.isReadOnly) {\r\n\t\t\tthrow new Error(\"The object is read only.\");\r\n\t\t}\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,86 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATN } from "./ATN";
import { ATNDeserializationOptions } from "./ATNDeserializationOptions";
import { ATNState } from "./ATNState";
import { ATNStateType } from "./ATNStateType";
import { IntervalSet } from "../misc/IntervalSet";
import { LexerAction } from "./LexerAction";
import { LexerActionType } from "./LexerActionType";
import { Transition } from "./Transition";
import { TransitionType } from "./TransitionType";
import { UUID } from "../misc/UUID";
/**
*
* @author Sam Harwell
*/
export declare class ATNDeserializer {
static get SERIALIZED_VERSION(): number;
/**
* This is the earliest supported serialized UUID.
*/
private static readonly BASE_SERIALIZED_UUID;
/**
* This UUID indicates an extension of {@link #ADDED_PRECEDENCE_TRANSITIONS}
* for the addition of lexer actions encoded as a sequence of
* {@link LexerAction} instances.
*/
private static readonly ADDED_LEXER_ACTIONS;
/**
* This UUID indicates the serialized ATN contains two sets of
* IntervalSets, where the second set's values are encoded as
* 32-bit integers to support the full Unicode SMP range up to U+10FFFF.
*/
private static readonly ADDED_UNICODE_SMP;
/**
* This list contains all of the currently supported UUIDs, ordered by when
* the feature first appeared in this branch.
*/
private static readonly SUPPORTED_UUIDS;
/**
* This is the current serialized UUID.
*/
private static readonly SERIALIZED_UUID;
private readonly deserializationOptions;
constructor(deserializationOptions?: ATNDeserializationOptions);
/**
* Determines if a particular serialized representation of an ATN supports
* a particular feature, identified by the {@link UUID} used for serializing
* the ATN at the time the feature was first introduced.
*
* @param feature The {@link UUID} marking the first time the feature was
* supported in the serialized ATN.
* @param actualUuid The {@link UUID} of the actual serialized ATN which is
* currently being deserialized.
* @returns `true` if the `actualUuid` value represents a
* serialized ATN at or after the feature identified by `feature` was
* introduced; otherwise, `false`.
*/
protected static isFeatureSupported(feature: UUID, actualUuid: UUID): boolean;
private static getUnicodeDeserializer;
deserialize(data: Uint16Array): ATN;
private deserializeSets;
/**
* Analyze the {@link StarLoopEntryState} states in the specified ATN to set
* the {@link StarLoopEntryState#precedenceRuleDecision} field to the
* correct value.
*
* @param atn The ATN.
*/
protected markPrecedenceDecisions(atn: ATN): void;
protected verifyATN(atn: ATN): void;
protected checkCondition(condition: boolean, message?: string): void;
private static inlineSetRules;
private static combineChainedEpsilons;
private static optimizeSets;
private static identifyTailCalls;
private static testTailCall;
protected static toInt(c: number): number;
protected static toInt32(data: Uint16Array, offset: number): number;
protected static toUUID(data: Uint16Array, offset: number): UUID;
protected edgeFactory(atn: ATN, type: TransitionType, src: number, trg: number, arg1: number, arg2: number, arg3: number, sets: IntervalSet[]): Transition;
protected stateFactory(type: ATNStateType, ruleIndex: number): ATNState;
protected lexerActionFactory(type: LexerActionType, data1: number, data2: number): LexerAction;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATN } from "./ATN";
import { DFAState } from "../dfa/DFAState";
export declare abstract class ATNSimulator {
/** Must distinguish between missing edge and edge we know leads nowhere */
private static _ERROR;
static get ERROR(): DFAState;
atn: ATN;
constructor(atn: ATN);
abstract reset(): void;
/**
* Clear the DFA cache used by the current instance. Since the DFA cache may
* be shared by multiple ATN simulators, this method may affect the
* performance (but not accuracy) of other parsers which are being used
* concurrently.
*
* @ if the current instance does not
* support clearing the DFA.
*
* @since 4.3
*/
clearDFA(): void;
}
export declare namespace ATNSimulator {
}

View File

@@ -0,0 +1,63 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNSimulator = void 0;
const ATNConfigSet_1 = require("./ATNConfigSet");
const DFAState_1 = require("../dfa/DFAState");
const Decorators_1 = require("../Decorators");
const PredictionContext_1 = require("./PredictionContext");
let ATNSimulator = class ATNSimulator {
constructor(atn) {
this.atn = atn;
}
static get ERROR() {
if (!ATNSimulator._ERROR) {
ATNSimulator._ERROR = new DFAState_1.DFAState(new ATNConfigSet_1.ATNConfigSet());
ATNSimulator._ERROR.stateNumber = PredictionContext_1.PredictionContext.EMPTY_FULL_STATE_KEY;
}
return ATNSimulator._ERROR;
}
/**
* Clear the DFA cache used by the current instance. Since the DFA cache may
* be shared by multiple ATN simulators, this method may affect the
* performance (but not accuracy) of other parsers which are being used
* concurrently.
*
* @ if the current instance does not
* support clearing the DFA.
*
* @since 4.3
*/
clearDFA() {
this.atn.clearDFA();
}
};
__decorate([
Decorators_1.NotNull
], ATNSimulator.prototype, "atn", void 0);
__decorate([
Decorators_1.NotNull
], ATNSimulator, "ERROR", null);
ATNSimulator = __decorate([
__param(0, Decorators_1.NotNull)
], ATNSimulator);
exports.ATNSimulator = ATNSimulator;
(function (ATNSimulator) {
const RULE_VARIANT_DELIMITER = "$";
const RULE_LF_VARIANT_MARKER = "$lf$";
const RULE_NOLF_VARIANT_MARKER = "$nolf$";
})(ATNSimulator = exports.ATNSimulator || (exports.ATNSimulator = {}));
exports.ATNSimulator = ATNSimulator;
//# sourceMappingURL=ATNSimulator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ATNSimulator.js","sourceRoot":"","sources":["../../../src/atn/ATNSimulator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAKH,iDAA8C;AAC9C,8CAA2C;AAC3C,8CAAwC;AACxC,2DAAwD;AAExD,IAAsB,YAAY,GAAlC,MAAsB,YAAY;IAgBjC,YAAqB,GAAQ;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IAdD,MAAM,KAAK,KAAK;QACf,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACzB,YAAY,CAAC,MAAM,GAAG,IAAI,mBAAQ,CAAC,IAAI,2BAAY,EAAE,CAAC,CAAC;YACvD,YAAY,CAAC,MAAM,CAAC,WAAW,GAAG,qCAAiB,CAAC,oBAAoB,CAAC;SACzE;QAED,OAAO,YAAY,CAAC,MAAM,CAAC;IAC5B,CAAC;IAWD;;;;;;;;;;OAUG;IACI,QAAQ;QACd,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC;CACD,CAAA;AAtBA;IADC,oBAAO;yCACQ;AAVhB;IADC,oBAAO;+BAQP;AAXoB,YAAY;IAgBpB,WAAA,oBAAO,CAAA;GAhBC,YAAY,CAoCjC;AApCqB,oCAAY;AAsClC,WAAiB,YAAY;IAC5B,MAAM,sBAAsB,GAAW,GAAG,CAAC;IAC3C,MAAM,sBAAsB,GAAW,MAAM,CAAC;IAC9C,MAAM,wBAAwB,GAAW,QAAQ,CAAC;AACnD,CAAC,EAJgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAI5B;AA1CqB,oCAAY","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.3184311-07:00\r\n\r\nimport { ATN } from \"./ATN\";\r\nimport { ATNConfigSet } from \"./ATNConfigSet\";\r\nimport { DFAState } from \"../dfa/DFAState\";\r\nimport { NotNull } from \"../Decorators\";\r\nimport { PredictionContext } from \"./PredictionContext\";\r\n\r\nexport abstract class ATNSimulator {\r\n\t/** Must distinguish between missing edge and edge we know leads nowhere */\r\n\tprivate static _ERROR: DFAState;\r\n\t@NotNull\r\n\tstatic get ERROR(): DFAState {\r\n\t\tif (!ATNSimulator._ERROR) {\r\n\t\t\tATNSimulator._ERROR = new DFAState(new ATNConfigSet());\r\n\t\t\tATNSimulator._ERROR.stateNumber = PredictionContext.EMPTY_FULL_STATE_KEY;\r\n\t\t}\r\n\r\n\t\treturn ATNSimulator._ERROR;\r\n\t}\r\n\r\n\t@NotNull\r\n\tpublic atn: ATN;\r\n\r\n\tconstructor(@NotNull atn: ATN) {\r\n\t\tthis.atn = atn;\r\n\t}\r\n\r\n\tpublic abstract reset(): void;\r\n\r\n\t/**\r\n\t * Clear the DFA cache used by the current instance. Since the DFA cache may\r\n\t * be shared by multiple ATN simulators, this method may affect the\r\n\t * performance (but not accuracy) of other parsers which are being used\r\n\t * concurrently.\r\n\t *\r\n\t * @ if the current instance does not\r\n\t * support clearing the DFA.\r\n\t *\r\n\t * @since 4.3\r\n\t */\r\n\tpublic clearDFA(): void {\r\n\t\tthis.atn.clearDFA();\r\n\t}\r\n}\r\n\r\nexport namespace ATNSimulator {\r\n\tconst RULE_VARIANT_DELIMITER: string = \"$\";\r\n\tconst RULE_LF_VARIANT_MARKER: string = \"$lf$\";\r\n\tconst RULE_NOLF_VARIANT_MARKER: string = \"$nolf$\";\r\n}\r\n"]}

View File

@@ -0,0 +1,111 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATN } from "./ATN";
import { ATNStateType } from "./ATNStateType";
import { IntervalSet } from "../misc/IntervalSet";
import { Transition } from "./Transition";
/**
* The following images show the relation of states and
* {@link ATNState#transitions} for various grammar constructs.
*
* * Solid edges marked with an &#0949; indicate a required
* {@link EpsilonTransition}.
*
* * Dashed edges indicate locations where any transition derived from
* {@link Transition} might appear.
*
* * Dashed nodes are place holders for either a sequence of linked
* {@link BasicState} states or the inclusion of a block representing a nested
* construct in one of the forms below.
*
* * Nodes showing multiple outgoing alternatives with a `...` support
* any number of alternatives (one or more). Nodes without the `...` only
* support the exact number of alternatives shown in the diagram.
*
* <h2>Basic Blocks</h2>
*
* <h3>Rule</h3>
*
* <embed src="images/Rule.svg" type="image/svg+xml"/>
*
* <h3>Block of 1 or more alternatives</h3>
*
* <embed src="images/Block.svg" type="image/svg+xml"/>
*
* <h2>Greedy Loops</h2>
*
* <h3>Greedy Closure: `(...)*`</h3>
*
* <embed src="images/ClosureGreedy.svg" type="image/svg+xml"/>
*
* <h3>Greedy Positive Closure: `(...)+`</h3>
*
* <embed src="images/PositiveClosureGreedy.svg" type="image/svg+xml"/>
*
* <h3>Greedy Optional: `(...)?`</h3>
*
* <embed src="images/OptionalGreedy.svg" type="image/svg+xml"/>
*
* <h2>Non-Greedy Loops</h2>
*
* <h3>Non-Greedy Closure: `(...)*?`</h3>
*
* <embed src="images/ClosureNonGreedy.svg" type="image/svg+xml"/>
*
* <h3>Non-Greedy Positive Closure: `(...)+?`</h3>
*
* <embed src="images/PositiveClosureNonGreedy.svg" type="image/svg+xml"/>
*
* <h3>Non-Greedy Optional: `(...)??`</h3>
*
* <embed src="images/OptionalNonGreedy.svg" type="image/svg+xml"/>
*/
export declare abstract class ATNState {
/** Which ATN are we in? */
atn?: ATN;
stateNumber: number;
ruleIndex: number;
epsilonOnlyTransitions: boolean;
/** Track the transitions emanating from this ATN state. */
protected transitions: Transition[];
protected optimizedTransitions: Transition[];
/** Used to cache lookahead during parsing, not used during construction */
nextTokenWithinRule?: IntervalSet;
/**
* Gets the state number.
*
* @returns the state number
*/
getStateNumber(): number;
/**
* For all states except {@link RuleStopState}, this returns the state
* number. Returns -1 for stop states.
*
* @returns -1 for {@link RuleStopState}, otherwise the state number
*/
get nonStopStateNumber(): number;
hashCode(): number;
equals(o: any): boolean;
get isNonGreedyExitState(): boolean;
toString(): string;
getTransitions(): Transition[];
get numberOfTransitions(): number;
addTransition(e: Transition, index?: number): void;
transition(i: number): Transition;
setTransition(i: number, e: Transition): void;
removeTransition(index: number): Transition;
abstract readonly stateType: ATNStateType;
get onlyHasEpsilonTransitions(): boolean;
setRuleIndex(ruleIndex: number): void;
get isOptimized(): boolean;
get numberOfOptimizedTransitions(): number;
getOptimizedTransition(i: number): Transition;
addOptimizedTransition(e: Transition): void;
setOptimizedTransition(i: number, e: Transition): void;
removeOptimizedTransition(i: number): void;
}
export declare namespace ATNState {
const INVALID_STATE_NUMBER: number;
}

View File

@@ -0,0 +1,186 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNState = void 0;
const Decorators_1 = require("../Decorators");
const INITIAL_NUM_TRANSITIONS = 4;
/**
* The following images show the relation of states and
* {@link ATNState#transitions} for various grammar constructs.
*
* * Solid edges marked with an &#0949; indicate a required
* {@link EpsilonTransition}.
*
* * Dashed edges indicate locations where any transition derived from
* {@link Transition} might appear.
*
* * Dashed nodes are place holders for either a sequence of linked
* {@link BasicState} states or the inclusion of a block representing a nested
* construct in one of the forms below.
*
* * Nodes showing multiple outgoing alternatives with a `...` support
* any number of alternatives (one or more). Nodes without the `...` only
* support the exact number of alternatives shown in the diagram.
*
* <h2>Basic Blocks</h2>
*
* <h3>Rule</h3>
*
* <embed src="images/Rule.svg" type="image/svg+xml"/>
*
* <h3>Block of 1 or more alternatives</h3>
*
* <embed src="images/Block.svg" type="image/svg+xml"/>
*
* <h2>Greedy Loops</h2>
*
* <h3>Greedy Closure: `(...)*`</h3>
*
* <embed src="images/ClosureGreedy.svg" type="image/svg+xml"/>
*
* <h3>Greedy Positive Closure: `(...)+`</h3>
*
* <embed src="images/PositiveClosureGreedy.svg" type="image/svg+xml"/>
*
* <h3>Greedy Optional: `(...)?`</h3>
*
* <embed src="images/OptionalGreedy.svg" type="image/svg+xml"/>
*
* <h2>Non-Greedy Loops</h2>
*
* <h3>Non-Greedy Closure: `(...)*?`</h3>
*
* <embed src="images/ClosureNonGreedy.svg" type="image/svg+xml"/>
*
* <h3>Non-Greedy Positive Closure: `(...)+?`</h3>
*
* <embed src="images/PositiveClosureNonGreedy.svg" type="image/svg+xml"/>
*
* <h3>Non-Greedy Optional: `(...)??`</h3>
*
* <embed src="images/OptionalNonGreedy.svg" type="image/svg+xml"/>
*/
class ATNState {
constructor() {
this.stateNumber = ATNState.INVALID_STATE_NUMBER;
this.ruleIndex = 0; // at runtime, we don't have Rule objects
this.epsilonOnlyTransitions = false;
/** Track the transitions emanating from this ATN state. */
this.transitions = [];
this.optimizedTransitions = this.transitions;
}
/**
* Gets the state number.
*
* @returns the state number
*/
getStateNumber() {
return this.stateNumber;
}
/**
* For all states except {@link RuleStopState}, this returns the state
* number. Returns -1 for stop states.
*
* @returns -1 for {@link RuleStopState}, otherwise the state number
*/
get nonStopStateNumber() {
return this.getStateNumber();
}
hashCode() {
return this.stateNumber;
}
equals(o) {
// are these states same object?
if (o instanceof ATNState) {
return this.stateNumber === o.stateNumber;
}
return false;
}
get isNonGreedyExitState() {
return false;
}
toString() {
return String(this.stateNumber);
}
getTransitions() {
return this.transitions.slice(0);
}
get numberOfTransitions() {
return this.transitions.length;
}
addTransition(e, index) {
if (this.transitions.length === 0) {
this.epsilonOnlyTransitions = e.isEpsilon;
}
else if (this.epsilonOnlyTransitions !== e.isEpsilon) {
this.epsilonOnlyTransitions = false;
throw new Error("ATN state " + this.stateNumber + " has both epsilon and non-epsilon transitions.");
}
this.transitions.splice(index !== undefined ? index : this.transitions.length, 0, e);
}
transition(i) {
return this.transitions[i];
}
setTransition(i, e) {
this.transitions[i] = e;
}
removeTransition(index) {
return this.transitions.splice(index, 1)[0];
}
get onlyHasEpsilonTransitions() {
return this.epsilonOnlyTransitions;
}
setRuleIndex(ruleIndex) {
this.ruleIndex = ruleIndex;
}
get isOptimized() {
return this.optimizedTransitions !== this.transitions;
}
get numberOfOptimizedTransitions() {
return this.optimizedTransitions.length;
}
getOptimizedTransition(i) {
return this.optimizedTransitions[i];
}
addOptimizedTransition(e) {
if (!this.isOptimized) {
this.optimizedTransitions = new Array();
}
this.optimizedTransitions.push(e);
}
setOptimizedTransition(i, e) {
if (!this.isOptimized) {
throw new Error("This ATNState is not optimized.");
}
this.optimizedTransitions[i] = e;
}
removeOptimizedTransition(i) {
if (!this.isOptimized) {
throw new Error("This ATNState is not optimized.");
}
this.optimizedTransitions.splice(i, 1);
}
}
__decorate([
Decorators_1.Override
], ATNState.prototype, "hashCode", null);
__decorate([
Decorators_1.Override
], ATNState.prototype, "equals", null);
__decorate([
Decorators_1.Override
], ATNState.prototype, "toString", null);
exports.ATNState = ATNState;
(function (ATNState) {
ATNState.INVALID_STATE_NUMBER = -1;
})(ATNState = exports.ATNState || (exports.ATNState = {}));
//# sourceMappingURL=ATNState.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
export declare enum ATNStateType {
INVALID_TYPE = 0,
BASIC = 1,
RULE_START = 2,
BLOCK_START = 3,
PLUS_BLOCK_START = 4,
STAR_BLOCK_START = 5,
TOKEN_START = 6,
RULE_STOP = 7,
BLOCK_END = 8,
STAR_LOOP_BACK = 9,
STAR_LOOP_ENTRY = 10,
PLUS_LOOP_BACK = 11,
LOOP_END = 12
}

View File

@@ -0,0 +1,25 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNStateType = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:27.4734328-07:00
var ATNStateType;
(function (ATNStateType) {
ATNStateType[ATNStateType["INVALID_TYPE"] = 0] = "INVALID_TYPE";
ATNStateType[ATNStateType["BASIC"] = 1] = "BASIC";
ATNStateType[ATNStateType["RULE_START"] = 2] = "RULE_START";
ATNStateType[ATNStateType["BLOCK_START"] = 3] = "BLOCK_START";
ATNStateType[ATNStateType["PLUS_BLOCK_START"] = 4] = "PLUS_BLOCK_START";
ATNStateType[ATNStateType["STAR_BLOCK_START"] = 5] = "STAR_BLOCK_START";
ATNStateType[ATNStateType["TOKEN_START"] = 6] = "TOKEN_START";
ATNStateType[ATNStateType["RULE_STOP"] = 7] = "RULE_STOP";
ATNStateType[ATNStateType["BLOCK_END"] = 8] = "BLOCK_END";
ATNStateType[ATNStateType["STAR_LOOP_BACK"] = 9] = "STAR_LOOP_BACK";
ATNStateType[ATNStateType["STAR_LOOP_ENTRY"] = 10] = "STAR_LOOP_ENTRY";
ATNStateType[ATNStateType["PLUS_LOOP_BACK"] = 11] = "PLUS_LOOP_BACK";
ATNStateType[ATNStateType["LOOP_END"] = 12] = "LOOP_END";
})(ATNStateType = exports.ATNStateType || (exports.ATNStateType = {}));
//# sourceMappingURL=ATNStateType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ATNStateType.js","sourceRoot":"","sources":["../../../src/atn/ATNStateType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,wDAAwD;AAExD,IAAY,YAcX;AAdD,WAAY,YAAY;IACvB,+DAAgB,CAAA;IAChB,iDAAS,CAAA;IACT,2DAAc,CAAA;IACd,6DAAe,CAAA;IACf,uEAAoB,CAAA;IACpB,uEAAoB,CAAA;IACpB,6DAAe,CAAA;IACf,yDAAa,CAAA;IACb,yDAAa,CAAA;IACb,mEAAkB,CAAA;IAClB,sEAAoB,CAAA;IACpB,oEAAmB,CAAA;IACnB,wDAAa,CAAA;AACd,CAAC,EAdW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAcvB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.4734328-07:00\r\n\r\nexport enum ATNStateType {\r\n\tINVALID_TYPE = 0,\r\n\tBASIC = 1,\r\n\tRULE_START = 2,\r\n\tBLOCK_START = 3,\r\n\tPLUS_BLOCK_START = 4,\r\n\tSTAR_BLOCK_START = 5,\r\n\tTOKEN_START = 6,\r\n\tRULE_STOP = 7,\r\n\tBLOCK_END = 8,\r\n\tSTAR_LOOP_BACK = 9,\r\n\tSTAR_LOOP_ENTRY = 10,\r\n\tPLUS_LOOP_BACK = 11,\r\n\tLOOP_END = 12,\r\n}\r\n"]}

View File

@@ -0,0 +1,19 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
/**
* Represents the type of recognizer an ATN applies to.
*
* @author Sam Harwell
*/
export declare const enum ATNType {
/**
* A lexer grammar.
*/
LEXER = 0,
/**
* A parser grammar.
*/
PARSER = 1
}

View File

@@ -0,0 +1,25 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATNType = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:27.6094030-07:00
/**
* Represents the type of recognizer an ATN applies to.
*
* @author Sam Harwell
*/
var ATNType;
(function (ATNType) {
/**
* A lexer grammar.
*/
ATNType[ATNType["LEXER"] = 0] = "LEXER";
/**
* A parser grammar.
*/
ATNType[ATNType["PARSER"] = 1] = "PARSER";
})(ATNType = exports.ATNType || (exports.ATNType = {}));
//# sourceMappingURL=ATNType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ATNType.js","sourceRoot":"","sources":["../../../src/atn/ATNType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,wDAAwD;AAExD;;;;GAIG;AACH,IAAkB,OAYjB;AAZD,WAAkB,OAAO;IAExB;;OAEG;IACH,uCAAK,CAAA;IAEL;;OAEG;IACH,yCAAM,CAAA;AAEP,CAAC,EAZiB,OAAO,GAAP,eAAO,KAAP,eAAO,QAYxB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.6094030-07:00\r\n\r\n/**\r\n * Represents the type of recognizer an ATN applies to.\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport const enum ATNType {\r\n\r\n\t/**\r\n\t * A lexer grammar.\r\n\t */\r\n\tLEXER,\r\n\r\n\t/**\r\n\t * A parser grammar.\r\n\t */\r\n\tPARSER,\r\n\r\n}\r\n"]}

View File

@@ -0,0 +1,13 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { Transition } from "./Transition";
/**
*
* @author Sam Harwell
*/
export declare abstract class AbstractPredicateTransition extends Transition {
constructor(target: ATNState);
}

View File

@@ -0,0 +1,19 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractPredicateTransition = void 0;
const Transition_1 = require("./Transition");
/**
*
* @author Sam Harwell
*/
class AbstractPredicateTransition extends Transition_1.Transition {
constructor(target) {
super(target);
}
}
exports.AbstractPredicateTransition = AbstractPredicateTransition;
//# sourceMappingURL=AbstractPredicateTransition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AbstractPredicateTransition.js","sourceRoot":"","sources":["../../../src/atn/AbstractPredicateTransition.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,6CAA0C;AAE1C;;;GAGG;AACH,MAAsB,2BAA4B,SAAQ,uBAAU;IAEnE,YAAY,MAAgB;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;CAED;AAND,kEAMC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:24.6596177-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { Transition } from \"./Transition\";\r\n\r\n/**\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport abstract class AbstractPredicateTransition extends Transition {\r\n\r\n\tconstructor(target: ATNState) {\r\n\t\tsuper(target);\r\n\t}\r\n\r\n}\r\n"]}

View File

@@ -0,0 +1,17 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { Transition } from "./Transition";
import { TransitionType } from "./TransitionType";
export declare class ActionTransition extends Transition {
ruleIndex: number;
actionIndex: number;
isCtxDependent: boolean;
constructor(target: ATNState, ruleIndex: number, actionIndex?: number, isCtxDependent?: boolean);
get serializationType(): TransitionType;
get isEpsilon(): boolean;
matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}

View File

@@ -0,0 +1,55 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionTransition = void 0;
const Decorators_1 = require("../Decorators");
const Transition_1 = require("./Transition");
let ActionTransition = class ActionTransition extends Transition_1.Transition {
constructor(target, ruleIndex, actionIndex = -1, isCtxDependent = false) {
super(target);
this.ruleIndex = ruleIndex;
this.actionIndex = actionIndex;
this.isCtxDependent = isCtxDependent;
}
get serializationType() {
return 6 /* ACTION */;
}
get isEpsilon() {
return true; // we are to be ignored by analysis 'cept for predicates
}
matches(symbol, minVocabSymbol, maxVocabSymbol) {
return false;
}
toString() {
return "action_" + this.ruleIndex + ":" + this.actionIndex;
}
};
__decorate([
Decorators_1.Override
], ActionTransition.prototype, "serializationType", null);
__decorate([
Decorators_1.Override
], ActionTransition.prototype, "isEpsilon", null);
__decorate([
Decorators_1.Override
], ActionTransition.prototype, "matches", null);
__decorate([
Decorators_1.Override
], ActionTransition.prototype, "toString", null);
ActionTransition = __decorate([
__param(0, Decorators_1.NotNull)
], ActionTransition);
exports.ActionTransition = ActionTransition;
//# sourceMappingURL=ActionTransition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ActionTransition.js","sourceRoot":"","sources":["../../../src/atn/ActionTransition.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAKH,8CAAkD;AAClD,6CAA0C;AAG1C,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,uBAAU;IAK/C,YAAqB,MAAgB,EAAE,SAAiB,EAAE,cAAsB,CAAC,CAAC,EAAE,iBAA0B,KAAK;QAClH,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;IAGD,IAAI,iBAAiB;QACpB,sBAA6B;IAC9B,CAAC;IAGD,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,CAAC,wDAAwD;IACtE,CAAC;IAGM,OAAO,CAAC,MAAc,EAAE,cAAsB,EAAE,cAAsB;QAC5E,OAAO,KAAK,CAAC;IACd,CAAC;IAGM,QAAQ;QACd,OAAO,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC;IAC5D,CAAC;CACD,CAAA;AAlBA;IADC,qBAAQ;yDAGR;AAGD;IADC,qBAAQ;iDAGR;AAGD;IADC,qBAAQ;+CAGR;AAGD;IADC,qBAAQ;gDAGR;AA9BW,gBAAgB;IAKf,WAAA,oBAAO,CAAA;GALR,gBAAgB,CA+B5B;AA/BY,4CAAgB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:24.7363448-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { Override, NotNull } from \"../Decorators\";\r\nimport { Transition } from \"./Transition\";\r\nimport { TransitionType } from \"./TransitionType\";\r\n\r\nexport class ActionTransition extends Transition {\r\n\tpublic ruleIndex: number;\r\n\tpublic actionIndex: number;\r\n\tpublic isCtxDependent: boolean; // e.g., $i ref in action\r\n\r\n\tconstructor(@NotNull target: ATNState, ruleIndex: number, actionIndex: number = -1, isCtxDependent: boolean = false) {\r\n\t\tsuper(target);\r\n\t\tthis.ruleIndex = ruleIndex;\r\n\t\tthis.actionIndex = actionIndex;\r\n\t\tthis.isCtxDependent = isCtxDependent;\r\n\t}\r\n\r\n\t@Override\r\n\tget serializationType(): TransitionType {\r\n\t\treturn TransitionType.ACTION;\r\n\t}\r\n\r\n\t@Override\r\n\tget isEpsilon(): boolean {\r\n\t\treturn true; // we are to be ignored by analysis 'cept for predicates\r\n\t}\r\n\r\n\t@Override\r\n\tpublic matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic toString(): string {\r\n\t\treturn \"action_\" + this.ruleIndex + \":\" + this.actionIndex;\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,60 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { BitSet } from "../misc/BitSet";
import { DecisionEventInfo } from "./DecisionEventInfo";
import { SimulatorState } from "./SimulatorState";
import { TokenStream } from "../TokenStream";
/**
* This class represents profiling event information for an ambiguity.
* Ambiguities are decisions where a particular input resulted in an SLL
* conflict, followed by LL prediction also reaching a conflict state
* (indicating a true ambiguity in the grammar).
*
* This event may be reported during SLL prediction in cases where the
* conflicting SLL configuration set provides sufficient information to
* determine that the SLL conflict is truly an ambiguity. For example, if none
* of the ATN configurations in the conflicting SLL configuration set have
* traversed a global follow transition (i.e.
* {@link ATNConfig#getReachesIntoOuterContext} is `false` for all
* configurations), then the result of SLL prediction for that input is known to
* be equivalent to the result of LL prediction for that input.
*
* In some cases, the minimum represented alternative in the conflicting LL
* configuration set is not equal to the minimum represented alternative in the
* conflicting SLL configuration set. Grammars and inputs which result in this
* scenario are unable to use {@link PredictionMode#SLL}, which in turn means
* they cannot use the two-stage parsing strategy to improve parsing performance
* for that input.
*
* @see ParserATNSimulator#reportAmbiguity
* @see ParserErrorListener#reportAmbiguity
*
* @since 4.3
*/
export declare class AmbiguityInfo extends DecisionEventInfo {
/** The set of alternative numbers for this decision event that lead to a valid parse. */
private ambigAlts;
/**
* Constructs a new instance of the {@link AmbiguityInfo} class with the
* specified detailed ambiguity information.
*
* @param decision The decision number
* @param state The final simulator state identifying the ambiguous
* alternatives for the current input
* @param ambigAlts The set of alternatives in the decision that lead to a valid parse.
* The predicted alt is the min(ambigAlts)
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the ambiguity was identified during
* prediction
*/
constructor(decision: number, state: SimulatorState, ambigAlts: BitSet, input: TokenStream, startIndex: number, stopIndex: number);
/**
* Gets the set of alternatives in the decision that lead to a valid parse.
*
* @since 4.5
*/
get ambiguousAlternatives(): BitSet;
}

View File

@@ -0,0 +1,86 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AmbiguityInfo = void 0;
const DecisionEventInfo_1 = require("./DecisionEventInfo");
const Decorators_1 = require("../Decorators");
/**
* This class represents profiling event information for an ambiguity.
* Ambiguities are decisions where a particular input resulted in an SLL
* conflict, followed by LL prediction also reaching a conflict state
* (indicating a true ambiguity in the grammar).
*
* This event may be reported during SLL prediction in cases where the
* conflicting SLL configuration set provides sufficient information to
* determine that the SLL conflict is truly an ambiguity. For example, if none
* of the ATN configurations in the conflicting SLL configuration set have
* traversed a global follow transition (i.e.
* {@link ATNConfig#getReachesIntoOuterContext} is `false` for all
* configurations), then the result of SLL prediction for that input is known to
* be equivalent to the result of LL prediction for that input.
*
* In some cases, the minimum represented alternative in the conflicting LL
* configuration set is not equal to the minimum represented alternative in the
* conflicting SLL configuration set. Grammars and inputs which result in this
* scenario are unable to use {@link PredictionMode#SLL}, which in turn means
* they cannot use the two-stage parsing strategy to improve parsing performance
* for that input.
*
* @see ParserATNSimulator#reportAmbiguity
* @see ParserErrorListener#reportAmbiguity
*
* @since 4.3
*/
let AmbiguityInfo = class AmbiguityInfo extends DecisionEventInfo_1.DecisionEventInfo {
/**
* Constructs a new instance of the {@link AmbiguityInfo} class with the
* specified detailed ambiguity information.
*
* @param decision The decision number
* @param state The final simulator state identifying the ambiguous
* alternatives for the current input
* @param ambigAlts The set of alternatives in the decision that lead to a valid parse.
* The predicted alt is the min(ambigAlts)
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the ambiguity was identified during
* prediction
*/
constructor(decision, state, ambigAlts, input, startIndex, stopIndex) {
super(decision, state, input, startIndex, stopIndex, state.useContext);
this.ambigAlts = ambigAlts;
}
/**
* Gets the set of alternatives in the decision that lead to a valid parse.
*
* @since 4.5
*/
get ambiguousAlternatives() {
return this.ambigAlts;
}
};
__decorate([
Decorators_1.NotNull
], AmbiguityInfo.prototype, "ambigAlts", void 0);
__decorate([
Decorators_1.NotNull
], AmbiguityInfo.prototype, "ambiguousAlternatives", null);
AmbiguityInfo = __decorate([
__param(1, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull),
__param(3, Decorators_1.NotNull)
], AmbiguityInfo);
exports.AmbiguityInfo = AmbiguityInfo;
//# sourceMappingURL=AmbiguityInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AmbiguityInfo.js","sourceRoot":"","sources":["../../../src/atn/AmbiguityInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAKH,2DAAwD;AACxD,8CAAwC;AAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,qCAAiB;IAKnD;;;;;;;;;;;;;OAaG;IACH,YACC,QAAgB,EACP,KAAqB,EACrB,SAAiB,EACjB,KAAkB,EAC3B,UAAkB,EAClB,SAAiB;QACjB,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACvE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IAEH,IAAI,qBAAqB;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;CACD,CAAA;AApCA;IADC,oBAAO;gDACkB;AAiC1B;IADC,oBAAO;0DAGP;AAtCW,aAAa;IAqBvB,WAAA,oBAAO,CAAA;IACP,WAAA,oBAAO,CAAA;IACP,WAAA,oBAAO,CAAA;GAvBG,aAAa,CAuCzB;AAvCY,sCAAa","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:24.8229279-07:00\r\n\r\nimport { BitSet } from \"../misc/BitSet\";\r\nimport { DecisionEventInfo } from \"./DecisionEventInfo\";\r\nimport { NotNull } from \"../Decorators\";\r\nimport { SimulatorState } from \"./SimulatorState\";\r\nimport { TokenStream } from \"../TokenStream\";\r\n\r\n/**\r\n * This class represents profiling event information for an ambiguity.\r\n * Ambiguities are decisions where a particular input resulted in an SLL\r\n * conflict, followed by LL prediction also reaching a conflict state\r\n * (indicating a true ambiguity in the grammar).\r\n *\r\n * This event may be reported during SLL prediction in cases where the\r\n * conflicting SLL configuration set provides sufficient information to\r\n * determine that the SLL conflict is truly an ambiguity. For example, if none\r\n * of the ATN configurations in the conflicting SLL configuration set have\r\n * traversed a global follow transition (i.e.\r\n * {@link ATNConfig#getReachesIntoOuterContext} is `false` for all\r\n * configurations), then the result of SLL prediction for that input is known to\r\n * be equivalent to the result of LL prediction for that input.\r\n *\r\n * In some cases, the minimum represented alternative in the conflicting LL\r\n * configuration set is not equal to the minimum represented alternative in the\r\n * conflicting SLL configuration set. Grammars and inputs which result in this\r\n * scenario are unable to use {@link PredictionMode#SLL}, which in turn means\r\n * they cannot use the two-stage parsing strategy to improve parsing performance\r\n * for that input.\r\n *\r\n * @see ParserATNSimulator#reportAmbiguity\r\n * @see ParserErrorListener#reportAmbiguity\r\n *\r\n * @since 4.3\r\n */\r\nexport class AmbiguityInfo extends DecisionEventInfo {\r\n\t/** The set of alternative numbers for this decision event that lead to a valid parse. */\r\n\t@NotNull\r\n\tprivate ambigAlts: BitSet;\r\n\r\n\t/**\r\n\t * Constructs a new instance of the {@link AmbiguityInfo} class with the\r\n\t * specified detailed ambiguity information.\r\n\t *\r\n\t * @param decision The decision number\r\n\t * @param state The final simulator state identifying the ambiguous\r\n\t * alternatives for the current input\r\n\t * @param ambigAlts The set of alternatives in the decision that lead to a valid parse.\r\n\t * The predicted alt is the min(ambigAlts)\r\n\t * @param input The input token stream\r\n\t * @param startIndex The start index for the current prediction\r\n\t * @param stopIndex The index at which the ambiguity was identified during\r\n\t * prediction\r\n\t */\r\n\tconstructor(\r\n\t\tdecision: number,\r\n\t\t@NotNull state: SimulatorState,\r\n\t\t@NotNull ambigAlts: BitSet,\r\n\t\t@NotNull input: TokenStream,\r\n\t\tstartIndex: number,\r\n\t\tstopIndex: number) {\r\n\t\tsuper(decision, state, input, startIndex, stopIndex, state.useContext);\r\n\t\tthis.ambigAlts = ambigAlts;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the set of alternatives in the decision that lead to a valid parse.\r\n\t *\r\n\t * @since 4.5\r\n\t */\r\n\t@NotNull\r\n\tget ambiguousAlternatives(): BitSet {\r\n\t\treturn this.ambigAlts;\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,18 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { IntervalSet } from "../misc/IntervalSet";
import { Transition } from "./Transition";
import { TransitionType } from "./TransitionType";
/** TODO: make all transitions sets? no, should remove set edges */
export declare class AtomTransition extends Transition {
/** The token type or character value; or, signifies special label. */
_label: number;
constructor(target: ATNState, label: number);
get serializationType(): TransitionType;
get label(): IntervalSet;
matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}

View File

@@ -0,0 +1,57 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AtomTransition = void 0;
const IntervalSet_1 = require("../misc/IntervalSet");
const Decorators_1 = require("../Decorators");
const Transition_1 = require("./Transition");
/** TODO: make all transitions sets? no, should remove set edges */
let AtomTransition = class AtomTransition extends Transition_1.Transition {
constructor(target, label) {
super(target);
this._label = label;
}
get serializationType() {
return 5 /* ATOM */;
}
get label() {
return IntervalSet_1.IntervalSet.of(this._label);
}
matches(symbol, minVocabSymbol, maxVocabSymbol) {
return this._label === symbol;
}
toString() {
return String(this.label);
}
};
__decorate([
Decorators_1.Override
], AtomTransition.prototype, "serializationType", null);
__decorate([
Decorators_1.Override,
Decorators_1.NotNull
], AtomTransition.prototype, "label", null);
__decorate([
Decorators_1.Override
], AtomTransition.prototype, "matches", null);
__decorate([
Decorators_1.Override,
Decorators_1.NotNull
], AtomTransition.prototype, "toString", null);
AtomTransition = __decorate([
__param(0, Decorators_1.NotNull)
], AtomTransition);
exports.AtomTransition = AtomTransition;
//# sourceMappingURL=AtomTransition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AtomTransition.js","sourceRoot":"","sources":["../../../src/atn/AtomTransition.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAKH,qDAAkD;AAClD,8CAAkD;AAClD,6CAA0C;AAG1C,mEAAmE;AACnE,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,uBAAU;IAI7C,YAAqB,MAAgB,EAAE,KAAa;QACnD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAGD,IAAI,iBAAiB;QACpB,oBAA2B;IAC5B,CAAC;IAID,IAAI,KAAK;QACR,OAAO,yBAAW,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAGM,OAAO,CAAC,MAAc,EAAE,cAAsB,EAAE,cAAsB;QAC5E,OAAO,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC;IAC/B,CAAC;IAIM,QAAQ;QACd,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;CACD,CAAA;AApBA;IADC,qBAAQ;uDAGR;AAID;IAFC,qBAAQ;IACR,oBAAO;2CAGP;AAGD;IADC,qBAAQ;6CAGR;AAID;IAFC,qBAAQ;IACR,oBAAO;8CAGP;AA7BW,cAAc;IAIb,WAAA,oBAAO,CAAA;GAJR,cAAc,CA8B1B;AA9BY,wCAAc","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.6769122-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { IntervalSet } from \"../misc/IntervalSet\";\r\nimport { Override, NotNull } from \"../Decorators\";\r\nimport { Transition } from \"./Transition\";\r\nimport { TransitionType } from \"./TransitionType\";\r\n\r\n/** TODO: make all transitions sets? no, should remove set edges */\r\nexport class AtomTransition extends Transition {\r\n\t/** The token type or character value; or, signifies special label. */\r\n\tpublic _label: number;\r\n\r\n\tconstructor(@NotNull target: ATNState, label: number) {\r\n\t\tsuper(target);\r\n\t\tthis._label = label;\r\n\t}\r\n\r\n\t@Override\r\n\tget serializationType(): TransitionType {\r\n\t\treturn TransitionType.ATOM;\r\n\t}\r\n\r\n\t@Override\r\n\t@NotNull\r\n\tget label(): IntervalSet {\r\n\t\treturn IntervalSet.of(this._label);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean {\r\n\t\treturn this._label === symbol;\r\n\t}\r\n\r\n\t@Override\r\n\t@NotNull\r\n\tpublic toString(): string {\r\n\t\treturn String(this.label);\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,13 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNStateType } from "./ATNStateType";
import { BlockStartState } from "./BlockStartState";
/**
*
* @author Sam Harwell
*/
export declare class BasicBlockStartState extends BlockStartState {
get stateType(): ATNStateType;
}

View File

@@ -0,0 +1,31 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasicBlockStartState = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:27.7669801-07:00
const ATNStateType_1 = require("./ATNStateType");
const BlockStartState_1 = require("./BlockStartState");
const Decorators_1 = require("../Decorators");
/**
*
* @author Sam Harwell
*/
class BasicBlockStartState extends BlockStartState_1.BlockStartState {
get stateType() {
return ATNStateType_1.ATNStateType.BLOCK_START;
}
}
__decorate([
Decorators_1.Override
], BasicBlockStartState.prototype, "stateType", null);
exports.BasicBlockStartState = BasicBlockStartState;
//# sourceMappingURL=BasicBlockStartState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BasicBlockStartState.js","sourceRoot":"","sources":["../../../src/atn/BasicBlockStartState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,wDAAwD;AAExD,iDAA8C;AAC9C,uDAAoD;AACpD,8CAAyC;AAEzC;;;GAGG;AACH,MAAa,oBAAqB,SAAQ,iCAAe;IAGxD,IAAI,SAAS;QACZ,OAAO,2BAAY,CAAC,WAAW,CAAC;IACjC,CAAC;CAED;AAJA;IADC,qBAAQ;qDAGR;AALF,oDAOC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.7669801-07:00\r\n\r\nimport { ATNStateType } from \"./ATNStateType\";\r\nimport { BlockStartState } from \"./BlockStartState\";\r\nimport { Override } from \"../Decorators\";\r\n\r\n/**\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport class BasicBlockStartState extends BlockStartState {\r\n\r\n\t@Override\r\n\tget stateType(): ATNStateType {\r\n\t\treturn ATNStateType.BLOCK_START;\r\n\t}\r\n\r\n}\r\n"]}

View File

@@ -0,0 +1,13 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { ATNStateType } from "./ATNStateType";
/**
*
* @author Sam Harwell
*/
export declare class BasicState extends ATNState {
get stateType(): ATNStateType;
}

View File

@@ -0,0 +1,31 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasicState = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:27.8389930-07:00
const ATNState_1 = require("./ATNState");
const ATNStateType_1 = require("./ATNStateType");
const Decorators_1 = require("../Decorators");
/**
*
* @author Sam Harwell
*/
class BasicState extends ATNState_1.ATNState {
get stateType() {
return ATNStateType_1.ATNStateType.BASIC;
}
}
__decorate([
Decorators_1.Override
], BasicState.prototype, "stateType", null);
exports.BasicState = BasicState;
//# sourceMappingURL=BasicState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BasicState.js","sourceRoot":"","sources":["../../../src/atn/BasicState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,wDAAwD;AAExD,yCAAsC;AACtC,iDAA8C;AAC9C,8CAAyC;AAEzC;;;GAGG;AACH,MAAa,UAAW,SAAQ,mBAAQ;IAGvC,IAAI,SAAS;QACZ,OAAO,2BAAY,CAAC,KAAK,CAAC;IAC3B,CAAC;CAED;AAJA;IADC,qBAAQ;2CAGR;AALF,gCAOC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.8389930-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { ATNStateType } from \"./ATNStateType\";\r\nimport { Override } from \"../Decorators\";\r\n\r\n/**\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport class BasicState extends ATNState {\r\n\r\n\t@Override\r\n\tget stateType(): ATNStateType {\r\n\t\treturn ATNStateType.BASIC;\r\n\t}\r\n\r\n}\r\n"]}

View File

@@ -0,0 +1,12 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { ATNStateType } from "./ATNStateType";
import { BlockStartState } from "./BlockStartState";
/** Terminal node of a simple `(a|b|c)` block. */
export declare class BlockEndState extends ATNState {
startState: BlockStartState;
get stateType(): ATNStateType;
}

View File

@@ -0,0 +1,28 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockEndState = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:27.9125304-07:00
const ATNState_1 = require("./ATNState");
const ATNStateType_1 = require("./ATNStateType");
const Decorators_1 = require("../Decorators");
/** Terminal node of a simple `(a|b|c)` block. */
class BlockEndState extends ATNState_1.ATNState {
get stateType() {
return ATNStateType_1.ATNStateType.BLOCK_END;
}
}
__decorate([
Decorators_1.Override
], BlockEndState.prototype, "stateType", null);
exports.BlockEndState = BlockEndState;
//# sourceMappingURL=BlockEndState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BlockEndState.js","sourceRoot":"","sources":["../../../src/atn/BlockEndState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAEH,wDAAwD;AAExD,yCAAsC;AACtC,iDAA8C;AAE9C,8CAAyC;AAEzC,iDAAiD;AACjD,MAAa,aAAc,SAAQ,mBAAQ;IAK1C,IAAI,SAAS;QACZ,OAAO,2BAAY,CAAC,SAAS,CAAC;IAC/B,CAAC;CACD;AAHA;IADC,qBAAQ;8CAGR;AAPF,sCAQC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.9125304-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { ATNStateType } from \"./ATNStateType\";\r\nimport { BlockStartState } from \"./BlockStartState\";\r\nimport { Override } from \"../Decorators\";\r\n\r\n/** Terminal node of a simple `(a|b|c)` block. */\r\nexport class BlockEndState extends ATNState {\r\n\t// This is always set during ATN deserialization\r\n\tpublic startState!: BlockStartState;\r\n\r\n\t@Override\r\n\tget stateType(): ATNStateType {\r\n\t\treturn ATNStateType.BLOCK_END;\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,10 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { BlockEndState } from "./BlockEndState";
import { DecisionState } from "./DecisionState";
/** The start of a regular `(...)` block. */
export declare abstract class BlockStartState extends DecisionState {
endState: BlockEndState;
}

View File

@@ -0,0 +1,13 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockStartState = void 0;
const DecisionState_1 = require("./DecisionState");
/** The start of a regular `(...)` block. */
class BlockStartState extends DecisionState_1.DecisionState {
}
exports.BlockStartState = BlockStartState;
//# sourceMappingURL=BlockStartState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BlockStartState.js","sourceRoot":"","sources":["../../../src/atn/BlockStartState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,mDAAgD;AAGhD,6CAA6C;AAC7C,MAAsB,eAAgB,SAAQ,6BAAa;CAG1D;AAHD,0CAGC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:27.9930394-07:00\r\n\r\nimport { BlockEndState } from \"./BlockEndState\";\r\nimport { DecisionState } from \"./DecisionState\";\r\nimport { Override } from \"../Decorators\";\r\n\r\n/** The start of a regular `(...)` block. */\r\nexport abstract class BlockStartState extends DecisionState {\r\n\t// This is always set during ATN deserialization\r\n\tpublic endState!: BlockEndState;\r\n}\r\n"]}

View File

@@ -0,0 +1,27 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { Transition } from "./Transition";
/**
* Utility functions to create {@link AtomTransition}, {@link RangeTransition},
* and {@link SetTransition} appropriately based on the range of the input.
*
* To keep the serialized ATN size small, we only inline atom and
* range transitions for Unicode code points <= U+FFFF.
*
* Whenever we encounter a Unicode code point > U+FFFF, we represent that
* as a set transition (even if it is logically an atom or a range).
*/
/**
* If {@code codePoint} is <= U+FFFF, returns a new {@link AtomTransition}.
* Otherwise, returns a new {@link SetTransition}.
*/
export declare function createWithCodePoint(target: ATNState, codePoint: number): Transition;
/**
* If {@code codePointFrom} and {@code codePointTo} are both
* <= U+FFFF, returns a new {@link RangeTransition}.
* Otherwise, returns a new {@link SetTransition}.
*/
export declare function createWithCodePointRange(target: ATNState, codePointFrom: number, codePointTo: number): Transition;

View File

@@ -0,0 +1,50 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createWithCodePointRange = exports.createWithCodePoint = void 0;
const Character = require("../misc/Character");
const AtomTransition_1 = require("./AtomTransition");
const IntervalSet_1 = require("../misc/IntervalSet");
const RangeTransition_1 = require("./RangeTransition");
const SetTransition_1 = require("./SetTransition");
/**
* Utility functions to create {@link AtomTransition}, {@link RangeTransition},
* and {@link SetTransition} appropriately based on the range of the input.
*
* To keep the serialized ATN size small, we only inline atom and
* range transitions for Unicode code points <= U+FFFF.
*
* Whenever we encounter a Unicode code point > U+FFFF, we represent that
* as a set transition (even if it is logically an atom or a range).
*/
/**
* If {@code codePoint} is <= U+FFFF, returns a new {@link AtomTransition}.
* Otherwise, returns a new {@link SetTransition}.
*/
function createWithCodePoint(target, codePoint) {
if (Character.isSupplementaryCodePoint(codePoint)) {
return new SetTransition_1.SetTransition(target, IntervalSet_1.IntervalSet.of(codePoint));
}
else {
return new AtomTransition_1.AtomTransition(target, codePoint);
}
}
exports.createWithCodePoint = createWithCodePoint;
/**
* If {@code codePointFrom} and {@code codePointTo} are both
* <= U+FFFF, returns a new {@link RangeTransition}.
* Otherwise, returns a new {@link SetTransition}.
*/
function createWithCodePointRange(target, codePointFrom, codePointTo) {
if (Character.isSupplementaryCodePoint(codePointFrom) || Character.isSupplementaryCodePoint(codePointTo)) {
return new SetTransition_1.SetTransition(target, IntervalSet_1.IntervalSet.of(codePointFrom, codePointTo));
}
else {
return new RangeTransition_1.RangeTransition(target, codePointFrom, codePointTo);
}
}
exports.createWithCodePointRange = createWithCodePointRange;
//# sourceMappingURL=CodePointTransitions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CodePointTransitions.js","sourceRoot":"","sources":["../../../src/atn/CodePointTransitions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+CAA+C;AAE/C,qDAAkD;AAClD,qDAAkD;AAClD,uDAAoD;AACpD,mDAAgD;AAGhD;;;;;;;;;GASG;AAEH;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,MAAgB,EAAE,SAAiB;IACtE,IAAI,SAAS,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE;QAClD,OAAO,IAAI,6BAAa,CAAC,MAAM,EAAE,yBAAW,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;KAC5D;SACI;QACJ,OAAO,IAAI,+BAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;KAC7C;AACF,CAAC;AAPD,kDAOC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,MAAgB,EAAE,aAAqB,EAAE,WAAmB;IACpG,IAAI,SAAS,CAAC,wBAAwB,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE;QACzG,OAAO,IAAI,6BAAa,CAAC,MAAM,EAAE,yBAAW,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;KAC7E;SACI;QACJ,OAAO,IAAI,iCAAe,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;KAC/D;AACF,CAAC;AAPD,4DAOC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\nimport * as Character from \"../misc/Character\";\r\nimport { ATNState } from \"./ATNState\";\r\nimport { AtomTransition } from \"./AtomTransition\";\r\nimport { IntervalSet } from \"../misc/IntervalSet\";\r\nimport { RangeTransition } from \"./RangeTransition\";\r\nimport { SetTransition } from \"./SetTransition\";\r\nimport { Transition } from \"./Transition\";\r\n\r\n/**\r\n * Utility functions to create {@link AtomTransition}, {@link RangeTransition},\r\n * and {@link SetTransition} appropriately based on the range of the input.\r\n *\r\n * To keep the serialized ATN size small, we only inline atom and\r\n * range transitions for Unicode code points <= U+FFFF.\r\n *\r\n * Whenever we encounter a Unicode code point > U+FFFF, we represent that\r\n * as a set transition (even if it is logically an atom or a range).\r\n */\r\n\r\n/**\r\n * If {@code codePoint} is <= U+FFFF, returns a new {@link AtomTransition}.\r\n * Otherwise, returns a new {@link SetTransition}.\r\n */\r\nexport function createWithCodePoint(target: ATNState, codePoint: number): Transition {\r\n\tif (Character.isSupplementaryCodePoint(codePoint)) {\r\n\t\treturn new SetTransition(target, IntervalSet.of(codePoint));\r\n\t}\r\n\telse {\r\n\t\treturn new AtomTransition(target, codePoint);\r\n\t}\r\n}\r\n\r\n/**\r\n * If {@code codePointFrom} and {@code codePointTo} are both\r\n * <= U+FFFF, returns a new {@link RangeTransition}.\r\n * Otherwise, returns a new {@link SetTransition}.\r\n */\r\nexport function createWithCodePointRange(target: ATNState, codePointFrom: number, codePointTo: number): Transition {\r\n\tif (Character.isSupplementaryCodePoint(codePointFrom) || Character.isSupplementaryCodePoint(codePointTo)) {\r\n\t\treturn new SetTransition(target, IntervalSet.of(codePointFrom, codePointTo));\r\n\t}\r\n\telse {\r\n\t\treturn new RangeTransition(target, codePointFrom, codePointTo);\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,35 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { BitSet } from "../misc/BitSet";
/**
* This class stores information about a configuration conflict.
*
* @author Sam Harwell
*/
export declare class ConflictInfo {
private _conflictedAlts;
private exact;
constructor(conflictedAlts: BitSet, exact: boolean);
/**
* Gets the set of conflicting alternatives for the configuration set.
*/
get conflictedAlts(): BitSet;
/**
* Gets whether or not the configuration conflict is an exact conflict.
* An exact conflict occurs when the prediction algorithm determines that
* the represented alternatives for a particular configuration set cannot be
* further reduced by consuming additional input. After reaching an exact
* conflict during an SLL prediction, only switch to full-context prediction
* could reduce the set of viable alternatives. In LL prediction, an exact
* conflict indicates a true ambiguity in the input.
*
* For the {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} prediction mode,
* accept states are conflicting but not exact are treated as non-accept
* states.
*/
get isExact(): boolean;
equals(obj: any): boolean;
hashCode(): number;
}

View File

@@ -0,0 +1,69 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConflictInfo = void 0;
const Decorators_1 = require("../Decorators");
const Utils = require("../misc/Utils");
/**
* This class stores information about a configuration conflict.
*
* @author Sam Harwell
*/
class ConflictInfo {
constructor(conflictedAlts, exact) {
this._conflictedAlts = conflictedAlts;
this.exact = exact;
}
/**
* Gets the set of conflicting alternatives for the configuration set.
*/
get conflictedAlts() {
return this._conflictedAlts;
}
/**
* Gets whether or not the configuration conflict is an exact conflict.
* An exact conflict occurs when the prediction algorithm determines that
* the represented alternatives for a particular configuration set cannot be
* further reduced by consuming additional input. After reaching an exact
* conflict during an SLL prediction, only switch to full-context prediction
* could reduce the set of viable alternatives. In LL prediction, an exact
* conflict indicates a true ambiguity in the input.
*
* For the {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} prediction mode,
* accept states are conflicting but not exact are treated as non-accept
* states.
*/
get isExact() {
return this.exact;
}
equals(obj) {
if (obj === this) {
return true;
}
else if (!(obj instanceof ConflictInfo)) {
return false;
}
return this.isExact === obj.isExact
&& Utils.equals(this.conflictedAlts, obj.conflictedAlts);
}
hashCode() {
return this.conflictedAlts.hashCode();
}
}
__decorate([
Decorators_1.Override
], ConflictInfo.prototype, "equals", null);
__decorate([
Decorators_1.Override
], ConflictInfo.prototype, "hashCode", null);
exports.ConflictInfo = ConflictInfo;
//# sourceMappingURL=ConflictInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConflictInfo.js","sourceRoot":"","sources":["../../../src/atn/ConflictInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAKH,8CAAyC;AACzC,uCAAuC;AAEvC;;;;GAIG;AACH,MAAa,YAAY;IAKxB,YAAY,cAAsB,EAAE,KAAc;QACjD,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAGM,MAAM,CAAC,GAAQ;QACrB,IAAI,GAAG,KAAK,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC;SACZ;aAAM,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC,EAAE;YAC1C,OAAO,KAAK,CAAC;SACb;QAED,OAAO,IAAI,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO;eAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3D,CAAC;IAGM,QAAQ;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACvC,CAAC;CACD;AAfA;IADC,qBAAQ;0CAUR;AAGD;IADC,qBAAQ;4CAGR;AAjDF,oCAkDC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.0710131-07:00\r\n\r\nimport { BitSet } from \"../misc/BitSet\";\r\nimport { Override } from \"../Decorators\";\r\nimport * as Utils from \"../misc/Utils\";\r\n\r\n/**\r\n * This class stores information about a configuration conflict.\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport class ConflictInfo {\r\n\tprivate _conflictedAlts: BitSet;\r\n\r\n\tprivate exact: boolean;\r\n\r\n\tconstructor(conflictedAlts: BitSet, exact: boolean) {\r\n\t\tthis._conflictedAlts = conflictedAlts;\r\n\t\tthis.exact = exact;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the set of conflicting alternatives for the configuration set.\r\n\t */\r\n\tget conflictedAlts(): BitSet {\r\n\t\treturn this._conflictedAlts;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets whether or not the configuration conflict is an exact conflict.\r\n\t * An exact conflict occurs when the prediction algorithm determines that\r\n\t * the represented alternatives for a particular configuration set cannot be\r\n\t * further reduced by consuming additional input. After reaching an exact\r\n\t * conflict during an SLL prediction, only switch to full-context prediction\r\n\t * could reduce the set of viable alternatives. In LL prediction, an exact\r\n\t * conflict indicates a true ambiguity in the input.\r\n\t *\r\n\t * For the {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} prediction mode,\r\n\t * accept states are conflicting but not exact are treated as non-accept\r\n\t * states.\r\n\t */\r\n\tget isExact(): boolean {\r\n\t\treturn this.exact;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic equals(obj: any): boolean {\r\n\t\tif (obj === this) {\r\n\t\t\treturn true;\r\n\t\t} else if (!(obj instanceof ConflictInfo)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this.isExact === obj.isExact\r\n\t\t\t&& Utils.equals(this.conflictedAlts, obj.conflictedAlts);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic hashCode(): number {\r\n\t\treturn this.conflictedAlts.hashCode();\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,39 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { DecisionEventInfo } from "./DecisionEventInfo";
import { SimulatorState } from "./SimulatorState";
import { TokenStream } from "../TokenStream";
/**
* This class represents profiling event information for a context sensitivity.
* Context sensitivities are decisions where a particular input resulted in an
* SLL conflict, but LL prediction produced a single unique alternative.
*
* In some cases, the unique alternative identified by LL prediction is not
* equal to the minimum represented alternative in the conflicting SLL
* configuration set. Grammars and inputs which result in this scenario are
* unable to use {@link PredictionMode#SLL}, which in turn means they cannot use
* the two-stage parsing strategy to improve parsing performance for that
* input.
*
* @see ParserATNSimulator#reportContextSensitivity
* @see ParserErrorListener#reportContextSensitivity
*
* @since 4.3
*/
export declare class ContextSensitivityInfo extends DecisionEventInfo {
/**
* Constructs a new instance of the {@link ContextSensitivityInfo} class
* with the specified detailed context sensitivity information.
*
* @param decision The decision number
* @param state The final simulator state containing the unique
* alternative identified by full-context prediction
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the context sensitivity was
* identified during full-context prediction
*/
constructor(decision: number, state: SimulatorState, input: TokenStream, startIndex: number, stopIndex: number);
}

View File

@@ -0,0 +1,59 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextSensitivityInfo = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:28.1575933-07:00
const DecisionEventInfo_1 = require("./DecisionEventInfo");
const Decorators_1 = require("../Decorators");
/**
* This class represents profiling event information for a context sensitivity.
* Context sensitivities are decisions where a particular input resulted in an
* SLL conflict, but LL prediction produced a single unique alternative.
*
* In some cases, the unique alternative identified by LL prediction is not
* equal to the minimum represented alternative in the conflicting SLL
* configuration set. Grammars and inputs which result in this scenario are
* unable to use {@link PredictionMode#SLL}, which in turn means they cannot use
* the two-stage parsing strategy to improve parsing performance for that
* input.
*
* @see ParserATNSimulator#reportContextSensitivity
* @see ParserErrorListener#reportContextSensitivity
*
* @since 4.3
*/
let ContextSensitivityInfo = class ContextSensitivityInfo extends DecisionEventInfo_1.DecisionEventInfo {
/**
* Constructs a new instance of the {@link ContextSensitivityInfo} class
* with the specified detailed context sensitivity information.
*
* @param decision The decision number
* @param state The final simulator state containing the unique
* alternative identified by full-context prediction
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the context sensitivity was
* identified during full-context prediction
*/
constructor(decision, state, input, startIndex, stopIndex) {
super(decision, state, input, startIndex, stopIndex, true);
}
};
ContextSensitivityInfo = __decorate([
__param(1, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull)
], ContextSensitivityInfo);
exports.ContextSensitivityInfo = ContextSensitivityInfo;
//# sourceMappingURL=ContextSensitivityInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ContextSensitivityInfo.js","sourceRoot":"","sources":["../../../src/atn/ContextSensitivityInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,wDAAwD;AAExD,2DAAwD;AACxD,8CAAwC;AAIxC;;;;;;;;;;;;;;;;GAgBG;AACH,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,qCAAiB;IAC5D;;;;;;;;;;;OAWG;IACH,YACC,QAAgB,EACP,KAAqB,EACrB,KAAkB,EAC3B,UAAkB,EAClB,SAAiB;QAEjB,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;CACD,CAAA;AAtBY,sBAAsB;IAehC,WAAA,oBAAO,CAAA;IACP,WAAA,oBAAO,CAAA;GAhBG,sBAAsB,CAsBlC;AAtBY,wDAAsB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.1575933-07:00\r\n\r\nimport { DecisionEventInfo } from \"./DecisionEventInfo\";\r\nimport { NotNull } from \"../Decorators\";\r\nimport { SimulatorState } from \"./SimulatorState\";\r\nimport { TokenStream } from \"../TokenStream\";\r\n\r\n/**\r\n * This class represents profiling event information for a context sensitivity.\r\n * Context sensitivities are decisions where a particular input resulted in an\r\n * SLL conflict, but LL prediction produced a single unique alternative.\r\n *\r\n * In some cases, the unique alternative identified by LL prediction is not\r\n * equal to the minimum represented alternative in the conflicting SLL\r\n * configuration set. Grammars and inputs which result in this scenario are\r\n * unable to use {@link PredictionMode#SLL}, which in turn means they cannot use\r\n * the two-stage parsing strategy to improve parsing performance for that\r\n * input.\r\n *\r\n * @see ParserATNSimulator#reportContextSensitivity\r\n * @see ParserErrorListener#reportContextSensitivity\r\n *\r\n * @since 4.3\r\n */\r\nexport class ContextSensitivityInfo extends DecisionEventInfo {\r\n\t/**\r\n\t * Constructs a new instance of the {@link ContextSensitivityInfo} class\r\n\t * with the specified detailed context sensitivity information.\r\n\t *\r\n\t * @param decision The decision number\r\n\t * @param state The final simulator state containing the unique\r\n\t * alternative identified by full-context prediction\r\n\t * @param input The input token stream\r\n\t * @param startIndex The start index for the current prediction\r\n\t * @param stopIndex The index at which the context sensitivity was\r\n\t * identified during full-context prediction\r\n\t */\r\n\tconstructor(\r\n\t\tdecision: number,\r\n\t\t@NotNull state: SimulatorState,\r\n\t\t@NotNull input: TokenStream,\r\n\t\tstartIndex: number,\r\n\t\tstopIndex: number) {\r\n\r\n\t\tsuper(decision, state, input, startIndex, stopIndex, true);\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,54 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { SimulatorState } from "./SimulatorState";
import { TokenStream } from "../TokenStream";
/**
* This is the base class for gathering detailed information about prediction
* events which occur during parsing.
*
* Note that we could record the parser call stack at the time this event
* occurred but in the presence of left recursive rules, the stack is kind of
* meaningless. It's better to look at the individual configurations for their
* individual stacks. Of course that is a {@link PredictionContext} object
* not a parse tree node and so it does not have information about the extent
* (start...stop) of the various subtrees. Examining the stack tops of all
* configurations provide the return states for the rule invocations.
* From there you can get the enclosing rule.
*
* @since 4.3
*/
export declare class DecisionEventInfo {
/**
* The invoked decision number which this event is related to.
*
* @see ATN#decisionToState
*/
decision: number;
/**
* The simulator state containing additional information relevant to the
* prediction state when the current event occurred, or `undefined` if no
* additional information is relevant or available.
*/
state: SimulatorState | undefined;
/**
* The input token stream which is being parsed.
*/
input: TokenStream;
/**
* The token index in the input stream at which the current prediction was
* originally invoked.
*/
startIndex: number;
/**
* The token index in the input stream at which the current event occurred.
*/
stopIndex: number;
/**
* `true` if the current event occurred during LL prediction;
* otherwise, `false` if the input occurred during SLL prediction.
*/
fullCtx: boolean;
constructor(decision: number, state: SimulatorState | undefined, input: TokenStream, startIndex: number, stopIndex: number, fullCtx: boolean);
}

View File

@@ -0,0 +1,51 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecisionEventInfo = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:28.2401032-07:00
const Decorators_1 = require("../Decorators");
/**
* This is the base class for gathering detailed information about prediction
* events which occur during parsing.
*
* Note that we could record the parser call stack at the time this event
* occurred but in the presence of left recursive rules, the stack is kind of
* meaningless. It's better to look at the individual configurations for their
* individual stacks. Of course that is a {@link PredictionContext} object
* not a parse tree node and so it does not have information about the extent
* (start...stop) of the various subtrees. Examining the stack tops of all
* configurations provide the return states for the rule invocations.
* From there you can get the enclosing rule.
*
* @since 4.3
*/
let DecisionEventInfo = class DecisionEventInfo {
constructor(decision, state, input, startIndex, stopIndex, fullCtx) {
this.decision = decision;
this.fullCtx = fullCtx;
this.stopIndex = stopIndex;
this.input = input;
this.startIndex = startIndex;
this.state = state;
}
};
__decorate([
Decorators_1.NotNull
], DecisionEventInfo.prototype, "input", void 0);
DecisionEventInfo = __decorate([
__param(2, Decorators_1.NotNull)
], DecisionEventInfo);
exports.DecisionEventInfo = DecisionEventInfo;
//# sourceMappingURL=DecisionEventInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DecisionEventInfo.js","sourceRoot":"","sources":["../../../src/atn/DecisionEventInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,wDAAwD;AAExD,8CAAwC;AAIxC;;;;;;;;;;;;;;GAcG;AACH,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAsC7B,YACC,QAAgB,EAChB,KAAiC,EACxB,KAAkB,EAC3B,UAAkB,EAClB,SAAiB,EACjB,OAAgB;QAEhB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;CACD,CAAA;AAlCA;IADC,oBAAO;gDACkB;AAnBd,iBAAiB;IAyC3B,WAAA,oBAAO,CAAA;GAzCG,iBAAiB,CAqD7B;AArDY,8CAAiB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.2401032-07:00\r\n\r\nimport { NotNull } from \"../Decorators\";\r\nimport { SimulatorState } from \"./SimulatorState\";\r\nimport { TokenStream } from \"../TokenStream\";\r\n\r\n/**\r\n * This is the base class for gathering detailed information about prediction\r\n * events which occur during parsing.\r\n *\r\n * Note that we could record the parser call stack at the time this event\r\n * occurred but in the presence of left recursive rules, the stack is kind of\r\n * meaningless. It's better to look at the individual configurations for their\r\n * individual stacks. Of course that is a {@link PredictionContext} object\r\n * not a parse tree node and so it does not have information about the extent\r\n * (start...stop) of the various subtrees. Examining the stack tops of all\r\n * configurations provide the return states for the rule invocations.\r\n * From there you can get the enclosing rule.\r\n *\r\n * @since 4.3\r\n */\r\nexport class DecisionEventInfo {\r\n\t/**\r\n\t * The invoked decision number which this event is related to.\r\n\t *\r\n\t * @see ATN#decisionToState\r\n\t */\r\n\tpublic decision: number;\r\n\r\n\t/**\r\n\t * The simulator state containing additional information relevant to the\r\n\t * prediction state when the current event occurred, or `undefined` if no\r\n\t * additional information is relevant or available.\r\n\t */\r\n\tpublic state: SimulatorState | undefined;\r\n\r\n\t/**\r\n\t * The input token stream which is being parsed.\r\n\t */\r\n\t@NotNull\r\n\tpublic input: TokenStream;\r\n\r\n\t/**\r\n\t * The token index in the input stream at which the current prediction was\r\n\t * originally invoked.\r\n\t */\r\n\tpublic startIndex: number;\r\n\r\n\t/**\r\n\t * The token index in the input stream at which the current event occurred.\r\n\t */\r\n\tpublic stopIndex: number;\r\n\r\n\t/**\r\n\t * `true` if the current event occurred during LL prediction;\r\n\t * otherwise, `false` if the input occurred during SLL prediction.\r\n\t */\r\n\tpublic fullCtx: boolean;\r\n\r\n\tconstructor(\r\n\t\tdecision: number,\r\n\t\tstate: SimulatorState | undefined,\r\n\t\t@NotNull input: TokenStream,\r\n\t\tstartIndex: number,\r\n\t\tstopIndex: number,\r\n\t\tfullCtx: boolean) {\r\n\r\n\t\tthis.decision = decision;\r\n\t\tthis.fullCtx = fullCtx;\r\n\t\tthis.stopIndex = stopIndex;\r\n\t\tthis.input = input;\r\n\t\tthis.startIndex = startIndex;\r\n\t\tthis.state = state;\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,201 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { AmbiguityInfo } from "./AmbiguityInfo";
import { ContextSensitivityInfo } from "./ContextSensitivityInfo";
import { ErrorInfo } from "./ErrorInfo";
import { LookaheadEventInfo } from "./LookaheadEventInfo";
import { PredicateEvalInfo } from "./PredicateEvalInfo";
/**
* This class contains profiling gathered for a particular decision.
*
* Parsing performance in ANTLR 4 is heavily influenced by both static factors
* (e.g. the form of the rules in the grammar) and dynamic factors (e.g. the
* choice of input and the state of the DFA cache at the time profiling
* operations are started). For best results, gather and use aggregate
* statistics from a large sample of inputs representing the inputs expected in
* production before using the results to make changes in the grammar.
*
* @since 4.3
*/
export declare class DecisionInfo {
/**
* The decision number, which is an index into {@link ATN#decisionToState}.
*/
decision: number;
/**
* The total number of times {@link ParserATNSimulator#adaptivePredict} was
* invoked for this decision.
*/
invocations: number;
/**
* The total time spent in {@link ParserATNSimulator#adaptivePredict} for
* this decision, in nanoseconds.
*
* The value of this field contains the sum of differential results obtained
* by {@link System#nanoTime()}, and is not adjusted to compensate for JIT
* and/or garbage collection overhead. For best accuracy, use a modern JVM
* implementation that provides precise results from
* {@link System#nanoTime()}, and perform profiling in a separate process
* which is warmed up by parsing the input prior to profiling. If desired,
* call {@link ATNSimulator#clearDFA} to reset the DFA cache to its initial
* state before starting the profiling measurement pass.
*/
timeInPrediction: number;
/**
* The sum of the lookahead required for SLL prediction for this decision.
* Note that SLL prediction is used before LL prediction for performance
* reasons even when {@link PredictionMode#LL} or
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
*/
SLL_TotalLook: number;
/**
* Gets the minimum lookahead required for any single SLL prediction to
* complete for this decision, by reaching a unique prediction, reaching an
* SLL conflict state, or encountering a syntax error.
*/
SLL_MinLook: number;
/**
* Gets the maximum lookahead required for any single SLL prediction to
* complete for this decision, by reaching a unique prediction, reaching an
* SLL conflict state, or encountering a syntax error.
*/
SLL_MaxLook: number;
/**
* Gets the {@link LookaheadEventInfo} associated with the event where the
* {@link #SLL_MaxLook} value was set.
*/
SLL_MaxLookEvent?: LookaheadEventInfo;
/**
* The sum of the lookahead required for LL prediction for this decision.
* Note that LL prediction is only used when SLL prediction reaches a
* conflict state.
*/
LL_TotalLook: number;
/**
* Gets the minimum lookahead required for any single LL prediction to
* complete for this decision. An LL prediction completes when the algorithm
* reaches a unique prediction, a conflict state (for
* {@link PredictionMode#LL}, an ambiguity state (for
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
*/
LL_MinLook: number;
/**
* Gets the maximum lookahead required for any single LL prediction to
* complete for this decision. An LL prediction completes when the algorithm
* reaches a unique prediction, a conflict state (for
* {@link PredictionMode#LL}, an ambiguity state (for
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
*/
LL_MaxLook: number;
/**
* Gets the {@link LookaheadEventInfo} associated with the event where the
* {@link #LL_MaxLook} value was set.
*/
LL_MaxLookEvent?: LookaheadEventInfo;
/**
* A collection of {@link ContextSensitivityInfo} instances describing the
* context sensitivities encountered during LL prediction for this decision.
*
* @see ContextSensitivityInfo
*/
contextSensitivities: ContextSensitivityInfo[];
/**
* A collection of {@link ErrorInfo} instances describing the parse errors
* identified during calls to {@link ParserATNSimulator#adaptivePredict} for
* this decision.
*
* @see ErrorInfo
*/
errors: ErrorInfo[];
/**
* A collection of {@link AmbiguityInfo} instances describing the
* ambiguities encountered during LL prediction for this decision.
*
* @see AmbiguityInfo
*/
ambiguities: AmbiguityInfo[];
/**
* A collection of {@link PredicateEvalInfo} instances describing the
* results of evaluating individual predicates during prediction for this
* decision.
*
* @see PredicateEvalInfo
*/
predicateEvals: PredicateEvalInfo[];
/**
* The total number of ATN transitions required during SLL prediction for
* this decision. An ATN transition is determined by the number of times the
* DFA does not contain an edge that is required for prediction, resulting
* in on-the-fly computation of that edge.
*
* If DFA caching of SLL transitions is employed by the implementation, ATN
* computation may cache the computed edge for efficient lookup during
* future parsing of this decision. Otherwise, the SLL parsing algorithm
* will use ATN transitions exclusively.
*
* @see #SLL_ATNTransitions
* @see ParserATNSimulator#computeTargetState
* @see LexerATNSimulator#computeTargetState
*/
SLL_ATNTransitions: number;
/**
* The total number of DFA transitions required during SLL prediction for
* this decision.
*
* If the ATN simulator implementation does not use DFA caching for SLL
* transitions, this value will be 0.
*
* @see ParserATNSimulator#getExistingTargetState
* @see LexerATNSimulator#getExistingTargetState
*/
SLL_DFATransitions: number;
/**
* Gets the total number of times SLL prediction completed in a conflict
* state, resulting in fallback to LL prediction.
*
* Note that this value is not related to whether or not
* {@link PredictionMode#SLL} may be used successfully with a particular
* grammar. If the ambiguity resolution algorithm applied to the SLL
* conflicts for this decision produce the same result as LL prediction for
* this decision, {@link PredictionMode#SLL} would produce the same overall
* parsing result as {@link PredictionMode#LL}.
*/
LL_Fallback: number;
/**
* The total number of ATN transitions required during LL prediction for
* this decision. An ATN transition is determined by the number of times the
* DFA does not contain an edge that is required for prediction, resulting
* in on-the-fly computation of that edge.
*
* If DFA caching of LL transitions is employed by the implementation, ATN
* computation may cache the computed edge for efficient lookup during
* future parsing of this decision. Otherwise, the LL parsing algorithm will
* use ATN transitions exclusively.
*
* @see #LL_DFATransitions
* @see ParserATNSimulator#computeTargetState
* @see LexerATNSimulator#computeTargetState
*/
LL_ATNTransitions: number;
/**
* The total number of DFA transitions required during LL prediction for
* this decision.
*
* If the ATN simulator implementation does not use DFA caching for LL
* transitions, this value will be 0.
*
* @see ParserATNSimulator#getExistingTargetState
* @see LexerATNSimulator#getExistingTargetState
*/
LL_DFATransitions: number;
/**
* Constructs a new instance of the {@link DecisionInfo} class to contain
* statistics for a particular decision.
*
* @param decision The decision number
*/
constructor(decision: number);
toString(): string;
}

View File

@@ -0,0 +1,212 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecisionInfo = void 0;
const Decorators_1 = require("../Decorators");
/**
* This class contains profiling gathered for a particular decision.
*
* Parsing performance in ANTLR 4 is heavily influenced by both static factors
* (e.g. the form of the rules in the grammar) and dynamic factors (e.g. the
* choice of input and the state of the DFA cache at the time profiling
* operations are started). For best results, gather and use aggregate
* statistics from a large sample of inputs representing the inputs expected in
* production before using the results to make changes in the grammar.
*
* @since 4.3
*/
class DecisionInfo {
/**
* Constructs a new instance of the {@link DecisionInfo} class to contain
* statistics for a particular decision.
*
* @param decision The decision number
*/
constructor(decision) {
/**
* The total number of times {@link ParserATNSimulator#adaptivePredict} was
* invoked for this decision.
*/
this.invocations = 0;
/**
* The total time spent in {@link ParserATNSimulator#adaptivePredict} for
* this decision, in nanoseconds.
*
* The value of this field contains the sum of differential results obtained
* by {@link System#nanoTime()}, and is not adjusted to compensate for JIT
* and/or garbage collection overhead. For best accuracy, use a modern JVM
* implementation that provides precise results from
* {@link System#nanoTime()}, and perform profiling in a separate process
* which is warmed up by parsing the input prior to profiling. If desired,
* call {@link ATNSimulator#clearDFA} to reset the DFA cache to its initial
* state before starting the profiling measurement pass.
*/
this.timeInPrediction = 0;
/**
* The sum of the lookahead required for SLL prediction for this decision.
* Note that SLL prediction is used before LL prediction for performance
* reasons even when {@link PredictionMode#LL} or
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION} is used.
*/
this.SLL_TotalLook = 0;
/**
* Gets the minimum lookahead required for any single SLL prediction to
* complete for this decision, by reaching a unique prediction, reaching an
* SLL conflict state, or encountering a syntax error.
*/
this.SLL_MinLook = 0;
/**
* Gets the maximum lookahead required for any single SLL prediction to
* complete for this decision, by reaching a unique prediction, reaching an
* SLL conflict state, or encountering a syntax error.
*/
this.SLL_MaxLook = 0;
/**
* The sum of the lookahead required for LL prediction for this decision.
* Note that LL prediction is only used when SLL prediction reaches a
* conflict state.
*/
this.LL_TotalLook = 0;
/**
* Gets the minimum lookahead required for any single LL prediction to
* complete for this decision. An LL prediction completes when the algorithm
* reaches a unique prediction, a conflict state (for
* {@link PredictionMode#LL}, an ambiguity state (for
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
*/
this.LL_MinLook = 0;
/**
* Gets the maximum lookahead required for any single LL prediction to
* complete for this decision. An LL prediction completes when the algorithm
* reaches a unique prediction, a conflict state (for
* {@link PredictionMode#LL}, an ambiguity state (for
* {@link PredictionMode#LL_EXACT_AMBIG_DETECTION}, or a syntax error.
*/
this.LL_MaxLook = 0;
/**
* A collection of {@link ContextSensitivityInfo} instances describing the
* context sensitivities encountered during LL prediction for this decision.
*
* @see ContextSensitivityInfo
*/
this.contextSensitivities = [];
/**
* A collection of {@link ErrorInfo} instances describing the parse errors
* identified during calls to {@link ParserATNSimulator#adaptivePredict} for
* this decision.
*
* @see ErrorInfo
*/
this.errors = [];
/**
* A collection of {@link AmbiguityInfo} instances describing the
* ambiguities encountered during LL prediction for this decision.
*
* @see AmbiguityInfo
*/
this.ambiguities = [];
/**
* A collection of {@link PredicateEvalInfo} instances describing the
* results of evaluating individual predicates during prediction for this
* decision.
*
* @see PredicateEvalInfo
*/
this.predicateEvals = [];
/**
* The total number of ATN transitions required during SLL prediction for
* this decision. An ATN transition is determined by the number of times the
* DFA does not contain an edge that is required for prediction, resulting
* in on-the-fly computation of that edge.
*
* If DFA caching of SLL transitions is employed by the implementation, ATN
* computation may cache the computed edge for efficient lookup during
* future parsing of this decision. Otherwise, the SLL parsing algorithm
* will use ATN transitions exclusively.
*
* @see #SLL_ATNTransitions
* @see ParserATNSimulator#computeTargetState
* @see LexerATNSimulator#computeTargetState
*/
this.SLL_ATNTransitions = 0;
/**
* The total number of DFA transitions required during SLL prediction for
* this decision.
*
* If the ATN simulator implementation does not use DFA caching for SLL
* transitions, this value will be 0.
*
* @see ParserATNSimulator#getExistingTargetState
* @see LexerATNSimulator#getExistingTargetState
*/
this.SLL_DFATransitions = 0;
/**
* Gets the total number of times SLL prediction completed in a conflict
* state, resulting in fallback to LL prediction.
*
* Note that this value is not related to whether or not
* {@link PredictionMode#SLL} may be used successfully with a particular
* grammar. If the ambiguity resolution algorithm applied to the SLL
* conflicts for this decision produce the same result as LL prediction for
* this decision, {@link PredictionMode#SLL} would produce the same overall
* parsing result as {@link PredictionMode#LL}.
*/
this.LL_Fallback = 0;
/**
* The total number of ATN transitions required during LL prediction for
* this decision. An ATN transition is determined by the number of times the
* DFA does not contain an edge that is required for prediction, resulting
* in on-the-fly computation of that edge.
*
* If DFA caching of LL transitions is employed by the implementation, ATN
* computation may cache the computed edge for efficient lookup during
* future parsing of this decision. Otherwise, the LL parsing algorithm will
* use ATN transitions exclusively.
*
* @see #LL_DFATransitions
* @see ParserATNSimulator#computeTargetState
* @see LexerATNSimulator#computeTargetState
*/
this.LL_ATNTransitions = 0;
/**
* The total number of DFA transitions required during LL prediction for
* this decision.
*
* If the ATN simulator implementation does not use DFA caching for LL
* transitions, this value will be 0.
*
* @see ParserATNSimulator#getExistingTargetState
* @see LexerATNSimulator#getExistingTargetState
*/
this.LL_DFATransitions = 0;
this.decision = decision;
}
toString() {
return "{" +
"decision=" + this.decision +
", contextSensitivities=" + this.contextSensitivities.length +
", errors=" + this.errors.length +
", ambiguities=" + this.ambiguities.length +
", SLL_lookahead=" + this.SLL_TotalLook +
", SLL_ATNTransitions=" + this.SLL_ATNTransitions +
", SLL_DFATransitions=" + this.SLL_DFATransitions +
", LL_Fallback=" + this.LL_Fallback +
", LL_lookahead=" + this.LL_TotalLook +
", LL_ATNTransitions=" + this.LL_ATNTransitions +
"}";
}
}
__decorate([
Decorators_1.Override
], DecisionInfo.prototype, "toString", null);
exports.DecisionInfo = DecisionInfo;
//# sourceMappingURL=DecisionInfo.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
export declare abstract class DecisionState extends ATNState {
decision: number;
nonGreedy: boolean;
sll: boolean;
}

View File

@@ -0,0 +1,19 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecisionState = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:28.4381103-07:00
const ATNState_1 = require("./ATNState");
class DecisionState extends ATNState_1.ATNState {
constructor() {
super(...arguments);
this.decision = -1;
this.nonGreedy = false;
this.sll = false;
}
}
exports.DecisionState = DecisionState;
//# sourceMappingURL=DecisionState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DecisionState.js","sourceRoot":"","sources":["../../../src/atn/DecisionState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,wDAAwD;AAExD,yCAAsC;AAEtC,MAAsB,aAAc,SAAQ,mBAAQ;IAApD;;QACQ,aAAQ,GAAW,CAAC,CAAC,CAAC;QACtB,cAAS,GAAY,KAAK,CAAC;QAC3B,QAAG,GAAY,KAAK,CAAC;IAC7B,CAAC;CAAA;AAJD,sCAIC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.4381103-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\n\r\nexport abstract class DecisionState extends ATNState {\r\n\tpublic decision: number = -1;\r\n\tpublic nonGreedy: boolean = false;\r\n\tpublic sll: boolean = false;\r\n}\r\n"]}

View File

@@ -0,0 +1,24 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNState } from "./ATNState";
import { Transition } from "./Transition";
import { TransitionType } from "./TransitionType";
export declare class EpsilonTransition extends Transition {
private _outermostPrecedenceReturn;
constructor(target: ATNState, outermostPrecedenceReturn?: number);
/**
* @returns the rule index of a precedence rule for which this transition is
* returning from, where the precedence value is 0; otherwise, -1.
*
* @see ATNConfig.isPrecedenceFilterSuppressed
* @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet, ParserRuleContext, PredictionContextCache)
* @since 4.4.1
*/
get outermostPrecedenceReturn(): number;
get serializationType(): TransitionType;
get isEpsilon(): boolean;
matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}

View File

@@ -0,0 +1,65 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EpsilonTransition = void 0;
const Decorators_1 = require("../Decorators");
const Transition_1 = require("./Transition");
let EpsilonTransition = class EpsilonTransition extends Transition_1.Transition {
constructor(target, outermostPrecedenceReturn = -1) {
super(target);
this._outermostPrecedenceReturn = outermostPrecedenceReturn;
}
/**
* @returns the rule index of a precedence rule for which this transition is
* returning from, where the precedence value is 0; otherwise, -1.
*
* @see ATNConfig.isPrecedenceFilterSuppressed
* @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet, ParserRuleContext, PredictionContextCache)
* @since 4.4.1
*/
get outermostPrecedenceReturn() {
return this._outermostPrecedenceReturn;
}
get serializationType() {
return 1 /* EPSILON */;
}
get isEpsilon() {
return true;
}
matches(symbol, minVocabSymbol, maxVocabSymbol) {
return false;
}
toString() {
return "epsilon";
}
};
__decorate([
Decorators_1.Override
], EpsilonTransition.prototype, "serializationType", null);
__decorate([
Decorators_1.Override
], EpsilonTransition.prototype, "isEpsilon", null);
__decorate([
Decorators_1.Override
], EpsilonTransition.prototype, "matches", null);
__decorate([
Decorators_1.Override,
Decorators_1.NotNull
], EpsilonTransition.prototype, "toString", null);
EpsilonTransition = __decorate([
__param(0, Decorators_1.NotNull)
], EpsilonTransition);
exports.EpsilonTransition = EpsilonTransition;
//# sourceMappingURL=EpsilonTransition.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EpsilonTransition.js","sourceRoot":"","sources":["../../../src/atn/EpsilonTransition.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAKH,8CAAkD;AAClD,6CAA0C;AAG1C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,uBAAU;IAIhD,YAAqB,MAAgB,EAAE,4BAAoC,CAAC,CAAC;QAC5E,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,yBAAyB;QAC5B,OAAO,IAAI,CAAC,0BAA0B,CAAC;IACxC,CAAC;IAGD,IAAI,iBAAiB;QACpB,uBAA8B;IAC/B,CAAC;IAGD,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAGM,OAAO,CAAC,MAAc,EAAE,cAAsB,EAAE,cAAsB;QAC5E,OAAO,KAAK,CAAC;IACd,CAAC;IAIM,QAAQ;QACd,OAAO,SAAS,CAAC;IAClB,CAAC;CACD,CAAA;AAnBA;IADC,qBAAQ;0DAGR;AAGD;IADC,qBAAQ;kDAGR;AAGD;IADC,qBAAQ;gDAGR;AAID;IAFC,qBAAQ;IACR,oBAAO;iDAGP;AAxCW,iBAAiB;IAIhB,WAAA,oBAAO,CAAA;GAJR,iBAAiB,CAyC7B;AAzCY,8CAAiB","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.6283213-07:00\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { Override, NotNull } from \"../Decorators\";\r\nimport { Transition } from \"./Transition\";\r\nimport { TransitionType } from \"./TransitionType\";\r\n\r\nexport class EpsilonTransition extends Transition {\r\n\r\n\tprivate _outermostPrecedenceReturn: number;\r\n\r\n\tconstructor(@NotNull target: ATNState, outermostPrecedenceReturn: number = -1) {\r\n\t\tsuper(target);\r\n\t\tthis._outermostPrecedenceReturn = outermostPrecedenceReturn;\r\n\t}\r\n\r\n\t/**\r\n\t * @returns the rule index of a precedence rule for which this transition is\r\n\t * returning from, where the precedence value is 0; otherwise, -1.\r\n\t *\r\n\t * @see ATNConfig.isPrecedenceFilterSuppressed\r\n\t * @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet, ParserRuleContext, PredictionContextCache)\r\n\t * @since 4.4.1\r\n\t */\r\n\tget outermostPrecedenceReturn(): number {\r\n\t\treturn this._outermostPrecedenceReturn;\r\n\t}\r\n\r\n\t@Override\r\n\tget serializationType(): TransitionType {\r\n\t\treturn TransitionType.EPSILON;\r\n\t}\r\n\r\n\t@Override\r\n\tget isEpsilon(): boolean {\r\n\t\treturn true;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t@Override\r\n\t@NotNull\r\n\tpublic toString(): string {\r\n\t\treturn \"epsilon\";\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,32 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { DecisionEventInfo } from "./DecisionEventInfo";
import { SimulatorState } from "./SimulatorState";
import { TokenStream } from "../TokenStream";
/**
* This class represents profiling event information for a syntax error
* identified during prediction. Syntax errors occur when the prediction
* algorithm is unable to identify an alternative which would lead to a
* successful parse.
*
* @see Parser#notifyErrorListeners(Token, String, RecognitionException)
* @see ANTLRErrorListener#syntaxError
*
* @since 4.3
*/
export declare class ErrorInfo extends DecisionEventInfo {
/**
* Constructs a new instance of the {@link ErrorInfo} class with the
* specified detailed syntax error information.
*
* @param decision The decision number
* @param state The final simulator state reached during prediction
* prior to reaching the {@link ATNSimulator#ERROR} state
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the syntax error was identified
*/
constructor(decision: number, state: SimulatorState, input: TokenStream, startIndex: number, stopIndex: number);
}

View File

@@ -0,0 +1,52 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorInfo = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:28.7213647-07:00
const DecisionEventInfo_1 = require("./DecisionEventInfo");
const Decorators_1 = require("../Decorators");
/**
* This class represents profiling event information for a syntax error
* identified during prediction. Syntax errors occur when the prediction
* algorithm is unable to identify an alternative which would lead to a
* successful parse.
*
* @see Parser#notifyErrorListeners(Token, String, RecognitionException)
* @see ANTLRErrorListener#syntaxError
*
* @since 4.3
*/
let ErrorInfo = class ErrorInfo extends DecisionEventInfo_1.DecisionEventInfo {
/**
* Constructs a new instance of the {@link ErrorInfo} class with the
* specified detailed syntax error information.
*
* @param decision The decision number
* @param state The final simulator state reached during prediction
* prior to reaching the {@link ATNSimulator#ERROR} state
* @param input The input token stream
* @param startIndex The start index for the current prediction
* @param stopIndex The index at which the syntax error was identified
*/
constructor(decision, state, input, startIndex, stopIndex) {
super(decision, state, input, startIndex, stopIndex, state.useContext);
}
};
ErrorInfo = __decorate([
__param(1, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull)
], ErrorInfo);
exports.ErrorInfo = ErrorInfo;
//# sourceMappingURL=ErrorInfo.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ErrorInfo.js","sourceRoot":"","sources":["../../../src/atn/ErrorInfo.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,wDAAwD;AAExD,2DAAwD;AACxD,8CAAwC;AAIxC;;;;;;;;;;GAUG;AACH,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,qCAAiB;IAC/C;;;;;;;;;;OAUG;IACH,YACC,QAAgB,EACP,KAAqB,EACrB,KAAkB,EAC3B,UAAkB,EAClB,SAAiB;QAEjB,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC;CACD,CAAA;AArBY,SAAS;IAcnB,WAAA,oBAAO,CAAA;IACP,WAAA,oBAAO,CAAA;GAfG,SAAS,CAqBrB;AArBY,8BAAS","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.7213647-07:00\r\n\r\nimport { DecisionEventInfo } from \"./DecisionEventInfo\";\r\nimport { NotNull } from \"../Decorators\";\r\nimport { SimulatorState } from \"./SimulatorState\";\r\nimport { TokenStream } from \"../TokenStream\";\r\n\r\n/**\r\n * This class represents profiling event information for a syntax error\r\n * identified during prediction. Syntax errors occur when the prediction\r\n * algorithm is unable to identify an alternative which would lead to a\r\n * successful parse.\r\n *\r\n * @see Parser#notifyErrorListeners(Token, String, RecognitionException)\r\n * @see ANTLRErrorListener#syntaxError\r\n *\r\n * @since 4.3\r\n */\r\nexport class ErrorInfo extends DecisionEventInfo {\r\n\t/**\r\n\t * Constructs a new instance of the {@link ErrorInfo} class with the\r\n\t * specified detailed syntax error information.\r\n\t *\r\n\t * @param decision The decision number\r\n\t * @param state The final simulator state reached during prediction\r\n\t * prior to reaching the {@link ATNSimulator#ERROR} state\r\n\t * @param input The input token stream\r\n\t * @param startIndex The start index for the current prediction\r\n\t * @param stopIndex The index at which the syntax error was identified\r\n\t */\r\n\tconstructor(\r\n\t\tdecision: number,\r\n\t\t@NotNull state: SimulatorState,\r\n\t\t@NotNull input: TokenStream,\r\n\t\tstartIndex: number,\r\n\t\tstopIndex: number) {\r\n\r\n\t\tsuper(decision, state, input, startIndex, stopIndex, state.useContext);\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,13 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATNStateType } from "./ATNStateType";
import { BasicState } from "./BasicState";
/**
*
* @author Sam Harwell
*/
export declare class InvalidState extends BasicState {
get stateType(): ATNStateType;
}

View File

@@ -0,0 +1,30 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidState = void 0;
const ATNStateType_1 = require("./ATNStateType");
const BasicState_1 = require("./BasicState");
const Decorators_1 = require("../Decorators");
/**
*
* @author Sam Harwell
*/
class InvalidState extends BasicState_1.BasicState {
get stateType() {
return ATNStateType_1.ATNStateType.INVALID_TYPE;
}
}
__decorate([
Decorators_1.Override
], InvalidState.prototype, "stateType", null);
exports.InvalidState = InvalidState;
//# sourceMappingURL=InvalidState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"InvalidState.js","sourceRoot":"","sources":["../../../src/atn/InvalidState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;AAGH,iDAA8C;AAC9C,6CAA0C;AAC1C,8CAAyC;AAEzC;;;GAGG;AACH,MAAa,YAAa,SAAQ,uBAAU;IAG3C,IAAI,SAAS;QACZ,OAAO,2BAAY,CAAC,YAAY,CAAC;IAClC,CAAC;CAED;AAJA;IADC,qBAAQ;6CAGR;AALF,oCAOC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\nimport { ATNState } from \"./ATNState\";\r\nimport { ATNStateType } from \"./ATNStateType\";\r\nimport { BasicState } from \"./BasicState\";\r\nimport { Override } from \"../Decorators\";\r\n\r\n/**\r\n *\r\n * @author Sam Harwell\r\n */\r\nexport class InvalidState extends BasicState {\r\n\r\n\t@Override\r\n\tget stateType(): ATNStateType {\r\n\t\treturn ATNStateType.INVALID_TYPE;\r\n\t}\r\n\r\n}\r\n"]}

View File

@@ -0,0 +1,98 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Array2DHashSet } from "../misc/Array2DHashSet";
import { ATN } from "./ATN";
import { ATNConfig } from "./ATNConfig";
import { ATNState } from "./ATNState";
import { BitSet } from "../misc/BitSet";
import { IntervalSet } from "../misc/IntervalSet";
import { PredictionContext } from "./PredictionContext";
export declare class LL1Analyzer {
/** Special value added to the lookahead sets to indicate that we hit
* a predicate during analysis if `seeThruPreds==false`.
*/
static readonly HIT_PRED: number;
atn: ATN;
constructor(atn: ATN);
/**
* Calculates the SLL(1) expected lookahead set for each outgoing transition
* of an {@link ATNState}. The returned array has one element for each
* outgoing transition in `s`. If the closure from transition
* *i* leads to a semantic predicate before matching a symbol, the
* element at index *i* of the result will be `undefined`.
*
* @param s the ATN state
* @returns the expected symbols for each outgoing transition of `s`.
*/
getDecisionLookahead(s: ATNState | undefined): Array<IntervalSet | undefined> | undefined;
/**
* Compute set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
*
* If `ctx` is `undefined` and the end of the rule containing
* `s` is reached, {@link Token#EPSILON} is added to the result set.
* If `ctx` is not `undefined` and the end of the outermost rule is
* reached, {@link Token#EOF} is added to the result set.
*
* @param s the ATN state
* @param ctx the complete parser context, or `undefined` if the context
* should be ignored
*
* @returns The set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
*/
LOOK(/*@NotNull*/ s: ATNState, /*@NotNull*/ ctx: PredictionContext): IntervalSet;
/**
* Compute set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
*
* If `ctx` is `undefined` and the end of the rule containing
* `s` is reached, {@link Token#EPSILON} is added to the result set.
* If `ctx` is not `PredictionContext#EMPTY_LOCAL` and the end of the outermost rule is
* reached, {@link Token#EOF} is added to the result set.
*
* @param s the ATN state
* @param stopState the ATN state to stop at. This can be a
* {@link BlockEndState} to detect epsilon paths through a closure.
* @param ctx the complete parser context, or `undefined` if the context
* should be ignored
*
* @returns The set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
*/
LOOK(/*@NotNull*/ s: ATNState, /*@NotNull*/ ctx: PredictionContext, stopState: ATNState | null): IntervalSet;
/**
* Compute set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
* <p/>
* If `ctx` is {@link PredictionContext#EMPTY_LOCAL} and
* `stopState` or the end of the rule containing `s` is reached,
* {@link Token#EPSILON} is added to the result set. If `ctx` is not
* {@link PredictionContext#EMPTY_LOCAL} and `addEOF` is `true`
* and `stopState` or the end of the outermost rule is reached,
* {@link Token#EOF} is added to the result set.
*
* @param s the ATN state.
* @param stopState the ATN state to stop at. This can be a
* {@link BlockEndState} to detect epsilon paths through a closure.
* @param ctx The outer context, or {@link PredictionContext#EMPTY_LOCAL} if
* the outer context should not be used.
* @param look The result lookahead set.
* @param lookBusy A set used for preventing epsilon closures in the ATN
* from causing a stack overflow. Outside code should pass
* `new HashSet<ATNConfig>` for this argument.
* @param calledRuleStack A set used for preventing left recursion in the
* ATN from causing a stack overflow. Outside code should pass
* `new BitSet()` for this argument.
* @param seeThruPreds `true` to true semantic predicates as
* implicitly `true` and "see through them", otherwise `false`
* to treat semantic predicates as opaque and add {@link #HIT_PRED} to the
* result if one is encountered.
* @param addEOF Add {@link Token#EOF} to the result if the end of the
* outermost context is reached. This parameter has no effect if `ctx`
* is {@link PredictionContext#EMPTY_LOCAL}.
*/
protected _LOOK(s: ATNState, stopState: ATNState | undefined, ctx: PredictionContext, look: IntervalSet, lookBusy: Array2DHashSet<ATNConfig>, calledRuleStack: BitSet, seeThruPreds: boolean, addEOF: boolean): void;
}

View File

@@ -0,0 +1,221 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LL1Analyzer = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:30.4445360-07:00
const AbstractPredicateTransition_1 = require("./AbstractPredicateTransition");
const Array2DHashSet_1 = require("../misc/Array2DHashSet");
const ATNConfig_1 = require("./ATNConfig");
const BitSet_1 = require("../misc/BitSet");
const IntervalSet_1 = require("../misc/IntervalSet");
const Decorators_1 = require("../Decorators");
const NotSetTransition_1 = require("./NotSetTransition");
const ObjectEqualityComparator_1 = require("../misc/ObjectEqualityComparator");
const PredictionContext_1 = require("./PredictionContext");
const RuleStopState_1 = require("./RuleStopState");
const RuleTransition_1 = require("./RuleTransition");
const Token_1 = require("../Token");
const WildcardTransition_1 = require("./WildcardTransition");
let LL1Analyzer = class LL1Analyzer {
constructor(atn) { this.atn = atn; }
/**
* Calculates the SLL(1) expected lookahead set for each outgoing transition
* of an {@link ATNState}. The returned array has one element for each
* outgoing transition in `s`. If the closure from transition
* *i* leads to a semantic predicate before matching a symbol, the
* element at index *i* of the result will be `undefined`.
*
* @param s the ATN state
* @returns the expected symbols for each outgoing transition of `s`.
*/
getDecisionLookahead(s) {
// System.out.println("LOOK("+s.stateNumber+")");
if (s == null) {
return undefined;
}
let look = new Array(s.numberOfTransitions);
for (let alt = 0; alt < s.numberOfTransitions; alt++) {
let current = new IntervalSet_1.IntervalSet();
look[alt] = current;
let lookBusy = new Array2DHashSet_1.Array2DHashSet(ObjectEqualityComparator_1.ObjectEqualityComparator.INSTANCE);
let seeThruPreds = false; // fail to get lookahead upon pred
this._LOOK(s.transition(alt).target, undefined, PredictionContext_1.PredictionContext.EMPTY_LOCAL, current, lookBusy, new BitSet_1.BitSet(), seeThruPreds, false);
// Wipe out lookahead for this alternative if we found nothing
// or we had a predicate when we !seeThruPreds
if (current.size === 0 || current.contains(LL1Analyzer.HIT_PRED)) {
current = undefined;
look[alt] = current;
}
}
return look;
}
LOOK(s, ctx, stopState) {
if (stopState === undefined) {
if (s.atn == null) {
throw new Error("Illegal state");
}
stopState = s.atn.ruleToStopState[s.ruleIndex];
}
else if (stopState === null) {
// This is an explicit request to pass undefined as the stopState to _LOOK. Used to distinguish an overload
// from the method which simply omits the stopState parameter.
stopState = undefined;
}
let r = new IntervalSet_1.IntervalSet();
let seeThruPreds = true; // ignore preds; get all lookahead
let addEOF = true;
this._LOOK(s, stopState, ctx, r, new Array2DHashSet_1.Array2DHashSet(), new BitSet_1.BitSet(), seeThruPreds, addEOF);
return r;
}
/**
* Compute set of tokens that can follow `s` in the ATN in the
* specified `ctx`.
* <p/>
* If `ctx` is {@link PredictionContext#EMPTY_LOCAL} and
* `stopState` or the end of the rule containing `s` is reached,
* {@link Token#EPSILON} is added to the result set. If `ctx` is not
* {@link PredictionContext#EMPTY_LOCAL} and `addEOF` is `true`
* and `stopState` or the end of the outermost rule is reached,
* {@link Token#EOF} is added to the result set.
*
* @param s the ATN state.
* @param stopState the ATN state to stop at. This can be a
* {@link BlockEndState} to detect epsilon paths through a closure.
* @param ctx The outer context, or {@link PredictionContext#EMPTY_LOCAL} if
* the outer context should not be used.
* @param look The result lookahead set.
* @param lookBusy A set used for preventing epsilon closures in the ATN
* from causing a stack overflow. Outside code should pass
* `new HashSet<ATNConfig>` for this argument.
* @param calledRuleStack A set used for preventing left recursion in the
* ATN from causing a stack overflow. Outside code should pass
* `new BitSet()` for this argument.
* @param seeThruPreds `true` to true semantic predicates as
* implicitly `true` and "see through them", otherwise `false`
* to treat semantic predicates as opaque and add {@link #HIT_PRED} to the
* result if one is encountered.
* @param addEOF Add {@link Token#EOF} to the result if the end of the
* outermost context is reached. This parameter has no effect if `ctx`
* is {@link PredictionContext#EMPTY_LOCAL}.
*/
_LOOK(s, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) {
// System.out.println("_LOOK("+s.stateNumber+", ctx="+ctx);
let c = ATNConfig_1.ATNConfig.create(s, 0, ctx);
if (!lookBusy.add(c)) {
return;
}
if (s === stopState) {
if (PredictionContext_1.PredictionContext.isEmptyLocal(ctx)) {
look.add(Token_1.Token.EPSILON);
return;
}
else if (ctx.isEmpty) {
if (addEOF) {
look.add(Token_1.Token.EOF);
}
return;
}
}
if (s instanceof RuleStopState_1.RuleStopState) {
if (ctx.isEmpty && !PredictionContext_1.PredictionContext.isEmptyLocal(ctx)) {
if (addEOF) {
look.add(Token_1.Token.EOF);
}
return;
}
let removed = calledRuleStack.get(s.ruleIndex);
try {
calledRuleStack.clear(s.ruleIndex);
for (let i = 0; i < ctx.size; i++) {
if (ctx.getReturnState(i) === PredictionContext_1.PredictionContext.EMPTY_FULL_STATE_KEY) {
continue;
}
let returnState = this.atn.states[ctx.getReturnState(i)];
// System.out.println("popping back to "+retState);
this._LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
}
}
finally {
if (removed) {
calledRuleStack.set(s.ruleIndex);
}
}
}
let n = s.numberOfTransitions;
for (let i = 0; i < n; i++) {
let t = s.transition(i);
if (t instanceof RuleTransition_1.RuleTransition) {
if (calledRuleStack.get(t.ruleIndex)) {
continue;
}
let newContext = ctx.getChild(t.followState.stateNumber);
try {
calledRuleStack.set(t.ruleIndex);
this._LOOK(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
}
finally {
calledRuleStack.clear(t.ruleIndex);
}
}
else if (t instanceof AbstractPredicateTransition_1.AbstractPredicateTransition) {
if (seeThruPreds) {
this._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
}
else {
look.add(LL1Analyzer.HIT_PRED);
}
}
else if (t.isEpsilon) {
this._LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
}
else if (t instanceof WildcardTransition_1.WildcardTransition) {
look.addAll(IntervalSet_1.IntervalSet.of(Token_1.Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
}
else {
// System.out.println("adding "+ t);
let set = t.label;
if (set != null) {
if (t instanceof NotSetTransition_1.NotSetTransition) {
set = set.complement(IntervalSet_1.IntervalSet.of(Token_1.Token.MIN_USER_TOKEN_TYPE, this.atn.maxTokenType));
}
look.addAll(set);
}
}
}
}
};
/** Special value added to the lookahead sets to indicate that we hit
* a predicate during analysis if `seeThruPreds==false`.
*/
LL1Analyzer.HIT_PRED = Token_1.Token.INVALID_TYPE;
__decorate([
Decorators_1.NotNull
], LL1Analyzer.prototype, "atn", void 0);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull)
], LL1Analyzer.prototype, "LOOK", null);
__decorate([
__param(0, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull),
__param(3, Decorators_1.NotNull),
__param(4, Decorators_1.NotNull),
__param(5, Decorators_1.NotNull)
], LL1Analyzer.prototype, "_LOOK", null);
LL1Analyzer = __decorate([
__param(0, Decorators_1.NotNull)
], LL1Analyzer);
exports.LL1Analyzer = LL1Analyzer;
//# sourceMappingURL=LL1Analyzer.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,153 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { ATN } from "./ATN";
import { ATNConfig } from "./ATNConfig";
import { ATNConfigSet } from "./ATNConfigSet";
import { ATNSimulator } from "./ATNSimulator";
import { ATNState } from "./ATNState";
import { CharStream } from "../CharStream";
import { DFA } from "../dfa/DFA";
import { DFAState } from "../dfa/DFAState";
import { Lexer } from "../Lexer";
import { LexerActionExecutor } from "./LexerActionExecutor";
import { Transition } from "./Transition";
/** "dup" of ParserInterpreter */
export declare class LexerATNSimulator extends ATNSimulator {
optimize_tail_calls: boolean;
protected recog: Lexer | undefined;
/** The current token's starting index into the character stream.
* Shared across DFA to ATN simulation in case the ATN fails and the
* DFA did not have a previous accept state. In this case, we use the
* ATN-generated exception object.
*/
protected startIndex: number;
/** line number 1..n within the input */
private _line;
/** The index of the character relative to the beginning of the line 0..n-1 */
private _charPositionInLine;
protected mode: number;
/** Used during DFA/ATN exec to record the most recent accept configuration info */
protected prevAccept: LexerATNSimulator.SimState;
constructor(/*@NotNull*/ atn: ATN);
constructor(/*@NotNull*/ atn: ATN, recog: Lexer | undefined);
copyState(simulator: LexerATNSimulator): void;
match(input: CharStream, mode: number): number;
reset(): void;
protected matchATN(input: CharStream): number;
protected execATN(input: CharStream, ds0: DFAState): number;
/**
* Get an existing target state for an edge in the DFA. If the target state
* for the edge has not yet been computed or is otherwise not available,
* this method returns `undefined`.
*
* @param s The current DFA state
* @param t The next input symbol
* @returns The existing target DFA state for the given input symbol
* `t`, or `undefined` if the target state for this edge is not
* already cached
*/
protected getExistingTargetState(s: DFAState, t: number): DFAState | undefined;
/**
* Compute a target state for an edge in the DFA, and attempt to add the
* computed state and corresponding edge to the DFA.
*
* @param input The input stream
* @param s The current DFA state
* @param t The next input symbol
*
* @returns The computed target DFA state for the given input symbol
* `t`. If `t` does not lead to a valid DFA state, this method
* returns {@link #ERROR}.
*/
protected computeTargetState(input: CharStream, s: DFAState, t: number): DFAState;
protected failOrAccept(prevAccept: LexerATNSimulator.SimState, input: CharStream, reach: ATNConfigSet, t: number): number;
/** Given a starting configuration set, figure out all ATN configurations
* we can reach upon input `t`. Parameter `reach` is a return
* parameter.
*/
protected getReachableConfigSet(input: CharStream, closure: ATNConfigSet, reach: ATNConfigSet, t: number): void;
protected accept(input: CharStream, lexerActionExecutor: LexerActionExecutor | undefined, startIndex: number, index: number, line: number, charPos: number): void;
protected getReachableTarget(trans: Transition, t: number): ATNState | undefined;
protected computeStartState(input: CharStream, p: ATNState): ATNConfigSet;
/**
* Since the alternatives within any lexer decision are ordered by
* preference, this method stops pursuing the closure as soon as an accept
* state is reached. After the first accept state is reached by depth-first
* search from `config`, all other (potentially reachable) states for
* this rule would have a lower priority.
*
* @returns `true` if an accept state is reached, otherwise
* `false`.
*/
protected closure(input: CharStream, config: ATNConfig, configs: ATNConfigSet, currentAltReachedAcceptState: boolean, speculative: boolean, treatEofAsEpsilon: boolean): boolean;
protected getEpsilonTarget(input: CharStream, config: ATNConfig, t: Transition, configs: ATNConfigSet, speculative: boolean, treatEofAsEpsilon: boolean): ATNConfig | undefined;
/**
* Evaluate a predicate specified in the lexer.
*
* If `speculative` is `true`, this method was called before
* {@link #consume} for the matched character. This method should call
* {@link #consume} before evaluating the predicate to ensure position
* sensitive values, including {@link Lexer#getText}, {@link Lexer#getLine},
* and {@link Lexer#getCharPositionInLine}, properly reflect the current
* lexer state. This method should restore `input` and the simulator
* to the original state before returning (i.e. undo the actions made by the
* call to {@link #consume}.
*
* @param input The input stream.
* @param ruleIndex The rule containing the predicate.
* @param predIndex The index of the predicate within the rule.
* @param speculative `true` if the current index in `input` is
* one character before the predicate's location.
*
* @returns `true` if the specified predicate evaluates to
* `true`.
*/
protected evaluatePredicate(input: CharStream, ruleIndex: number, predIndex: number, speculative: boolean): boolean;
protected captureSimState(settings: LexerATNSimulator.SimState, input: CharStream, dfaState: DFAState): void;
protected addDFAEdge(/*@NotNull*/ p: DFAState, t: number, /*@NotNull*/ q: ATNConfigSet): DFAState;
protected addDFAEdge(/*@NotNull*/ p: DFAState, t: number, /*@NotNull*/ q: DFAState): void;
/** Add a new DFA state if there isn't one with this set of
* configurations already. This method also detects the first
* configuration containing an ATN rule stop state. Later, when
* traversing the DFA, we will know which rule to accept.
*/
protected addDFAState(configs: ATNConfigSet): DFAState;
getDFA(mode: number): DFA;
/** Get the text matched so far for the current token.
*/
getText(input: CharStream): string;
get line(): number;
set line(line: number);
get charPositionInLine(): number;
set charPositionInLine(charPositionInLine: number);
consume(input: CharStream): void;
getTokenName(t: number): string;
}
export declare namespace LexerATNSimulator {
const debug: boolean;
const dfa_debug: boolean;
/** When we hit an accept state in either the DFA or the ATN, we
* have to notify the character stream to start buffering characters
* via {@link IntStream#mark} and record the current state. The current sim state
* includes the current index into the input, the current line,
* and current character position in that line. Note that the Lexer is
* tracking the starting line and characterization of the token. These
* variables track the "state" of the simulator when it hits an accept state.
*
* We track these variables separately for the DFA and ATN simulation
* because the DFA simulation often has to fail over to the ATN
* simulation. If the ATN simulation fails, we need the DFA to fall
* back to its previously accepted state, if any. If the ATN succeeds,
* then the ATN does the accept and the DFA simulator that invoked it
* can simply return the predicted token type.
*/
class SimState {
index: number;
line: number;
charPos: number;
dfaState?: DFAState;
reset(): void;
}
}

View File

@@ -0,0 +1,716 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexerATNSimulator = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:29.1083066-07:00
const AcceptStateInfo_1 = require("../dfa/AcceptStateInfo");
const ATN_1 = require("./ATN");
const ATNConfig_1 = require("./ATNConfig");
const ATNConfigSet_1 = require("./ATNConfigSet");
const ATNSimulator_1 = require("./ATNSimulator");
const DFAState_1 = require("../dfa/DFAState");
const Interval_1 = require("../misc/Interval");
const IntStream_1 = require("../IntStream");
const Lexer_1 = require("../Lexer");
const LexerActionExecutor_1 = require("./LexerActionExecutor");
const LexerNoViableAltException_1 = require("../LexerNoViableAltException");
const Decorators_1 = require("../Decorators");
const OrderedATNConfigSet_1 = require("./OrderedATNConfigSet");
const PredictionContext_1 = require("./PredictionContext");
const RuleStopState_1 = require("./RuleStopState");
const Token_1 = require("../Token");
const assert = require("assert");
/** "dup" of ParserInterpreter */
let LexerATNSimulator = class LexerATNSimulator extends ATNSimulator_1.ATNSimulator {
constructor(atn, recog) {
super(atn);
this.optimize_tail_calls = true;
/** The current token's starting index into the character stream.
* Shared across DFA to ATN simulation in case the ATN fails and the
* DFA did not have a previous accept state. In this case, we use the
* ATN-generated exception object.
*/
this.startIndex = -1;
/** line number 1..n within the input */
this._line = 1;
/** The index of the character relative to the beginning of the line 0..n-1 */
this._charPositionInLine = 0;
this.mode = Lexer_1.Lexer.DEFAULT_MODE;
/** Used during DFA/ATN exec to record the most recent accept configuration info */
this.prevAccept = new LexerATNSimulator.SimState();
this.recog = recog;
}
copyState(simulator) {
this._charPositionInLine = simulator.charPositionInLine;
this._line = simulator._line;
this.mode = simulator.mode;
this.startIndex = simulator.startIndex;
}
match(input, mode) {
this.mode = mode;
let mark = input.mark();
try {
this.startIndex = input.index;
this.prevAccept.reset();
let s0 = this.atn.modeToDFA[mode].s0;
if (s0 == null) {
return this.matchATN(input);
}
else {
return this.execATN(input, s0);
}
}
finally {
input.release(mark);
}
}
reset() {
this.prevAccept.reset();
this.startIndex = -1;
this._line = 1;
this._charPositionInLine = 0;
this.mode = Lexer_1.Lexer.DEFAULT_MODE;
}
matchATN(input) {
let startState = this.atn.modeToStartState[this.mode];
if (LexerATNSimulator.debug) {
console.log(`matchATN mode ${this.mode} start: ${startState}`);
}
let old_mode = this.mode;
let s0_closure = this.computeStartState(input, startState);
let suppressEdge = s0_closure.hasSemanticContext;
if (suppressEdge) {
s0_closure.hasSemanticContext = false;
}
let next = this.addDFAState(s0_closure);
if (!suppressEdge) {
let dfa = this.atn.modeToDFA[this.mode];
if (!dfa.s0) {
dfa.s0 = next;
}
else {
next = dfa.s0;
}
}
let predict = this.execATN(input, next);
if (LexerATNSimulator.debug) {
console.log(`DFA after matchATN: ${this.atn.modeToDFA[old_mode].toLexerString()}`);
}
return predict;
}
execATN(input, ds0) {
// console.log("enter exec index "+input.index+" from "+ds0.configs);
if (LexerATNSimulator.debug) {
console.log(`start state closure=${ds0.configs}`);
}
if (ds0.isAcceptState) {
// allow zero-length tokens
this.captureSimState(this.prevAccept, input, ds0);
}
let t = input.LA(1);
// @NotNull
let s = ds0; // s is current/from DFA state
while (true) { // while more work
if (LexerATNSimulator.debug) {
console.log(`execATN loop starting closure: ${s.configs}`);
}
// As we move src->trg, src->trg, we keep track of the previous trg to
// avoid looking up the DFA state again, which is expensive.
// If the previous target was already part of the DFA, we might
// be able to avoid doing a reach operation upon t. If s!=null,
// it means that semantic predicates didn't prevent us from
// creating a DFA state. Once we know s!=null, we check to see if
// the DFA state has an edge already for t. If so, we can just reuse
// it's configuration set; there's no point in re-computing it.
// This is kind of like doing DFA simulation within the ATN
// simulation because DFA simulation is really just a way to avoid
// computing reach/closure sets. Technically, once we know that
// we have a previously added DFA state, we could jump over to
// the DFA simulator. But, that would mean popping back and forth
// a lot and making things more complicated algorithmically.
// This optimization makes a lot of sense for loops within DFA.
// A character will take us back to an existing DFA state
// that already has lots of edges out of it. e.g., .* in comments.
let target = this.getExistingTargetState(s, t);
if (target == null) {
target = this.computeTargetState(input, s, t);
}
if (target === ATNSimulator_1.ATNSimulator.ERROR) {
break;
}
// If this is a consumable input element, make sure to consume before
// capturing the accept state so the input index, line, and char
// position accurately reflect the state of the interpreter at the
// end of the token.
if (t !== IntStream_1.IntStream.EOF) {
this.consume(input);
}
if (target.isAcceptState) {
this.captureSimState(this.prevAccept, input, target);
if (t === IntStream_1.IntStream.EOF) {
break;
}
}
t = input.LA(1);
s = target; // flip; current DFA target becomes new src/from state
}
return this.failOrAccept(this.prevAccept, input, s.configs, t);
}
/**
* Get an existing target state for an edge in the DFA. If the target state
* for the edge has not yet been computed or is otherwise not available,
* this method returns `undefined`.
*
* @param s The current DFA state
* @param t The next input symbol
* @returns The existing target DFA state for the given input symbol
* `t`, or `undefined` if the target state for this edge is not
* already cached
*/
getExistingTargetState(s, t) {
let target = s.getTarget(t);
if (LexerATNSimulator.debug && target != null) {
console.log("reuse state " + s.stateNumber +
" edge to " + target.stateNumber);
}
return target;
}
/**
* Compute a target state for an edge in the DFA, and attempt to add the
* computed state and corresponding edge to the DFA.
*
* @param input The input stream
* @param s The current DFA state
* @param t The next input symbol
*
* @returns The computed target DFA state for the given input symbol
* `t`. If `t` does not lead to a valid DFA state, this method
* returns {@link #ERROR}.
*/
computeTargetState(input, s, t) {
let reach = new OrderedATNConfigSet_1.OrderedATNConfigSet();
// if we don't find an existing DFA state
// Fill reach starting from closure, following t transitions
this.getReachableConfigSet(input, s.configs, reach, t);
if (reach.isEmpty) { // we got nowhere on t from s
if (!reach.hasSemanticContext) {
// we got nowhere on t, don't throw out this knowledge; it'd
// cause a failover from DFA later.
this.addDFAEdge(s, t, ATNSimulator_1.ATNSimulator.ERROR);
}
// stop when we can't match any more char
return ATNSimulator_1.ATNSimulator.ERROR;
}
// Add an edge from s to target DFA found/created for reach
return this.addDFAEdge(s, t, reach);
}
failOrAccept(prevAccept, input, reach, t) {
if (prevAccept.dfaState != null) {
let lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor;
this.accept(input, lexerActionExecutor, this.startIndex, prevAccept.index, prevAccept.line, prevAccept.charPos);
return prevAccept.dfaState.prediction;
}
else {
// if no accept and EOF is first char, return EOF
if (t === IntStream_1.IntStream.EOF && input.index === this.startIndex) {
return Token_1.Token.EOF;
}
throw new LexerNoViableAltException_1.LexerNoViableAltException(this.recog, input, this.startIndex, reach);
}
}
/** Given a starting configuration set, figure out all ATN configurations
* we can reach upon input `t`. Parameter `reach` is a return
* parameter.
*/
getReachableConfigSet(input, closure, reach, t) {
// this is used to skip processing for configs which have a lower priority
// than a config that already reached an accept state for the same rule
let skipAlt = ATN_1.ATN.INVALID_ALT_NUMBER;
for (let c of closure) {
let currentAltReachedAcceptState = c.alt === skipAlt;
if (currentAltReachedAcceptState && c.hasPassedThroughNonGreedyDecision) {
continue;
}
if (LexerATNSimulator.debug) {
console.log(`testing ${this.getTokenName(t)} at ${c.toString(this.recog, true)}`);
}
let n = c.state.numberOfOptimizedTransitions;
for (let ti = 0; ti < n; ti++) { // for each optimized transition
let trans = c.state.getOptimizedTransition(ti);
let target = this.getReachableTarget(trans, t);
if (target != null) {
let lexerActionExecutor = c.lexerActionExecutor;
let config;
if (lexerActionExecutor != null) {
lexerActionExecutor = lexerActionExecutor.fixOffsetBeforeMatch(input.index - this.startIndex);
config = c.transform(target, true, lexerActionExecutor);
}
else {
assert(c.lexerActionExecutor == null);
config = c.transform(target, true);
}
let treatEofAsEpsilon = t === IntStream_1.IntStream.EOF;
if (this.closure(input, config, reach, currentAltReachedAcceptState, true, treatEofAsEpsilon)) {
// any remaining configs for this alt have a lower priority than
// the one that just reached an accept state.
skipAlt = c.alt;
break;
}
}
}
}
}
accept(input, lexerActionExecutor, startIndex, index, line, charPos) {
if (LexerATNSimulator.debug) {
console.log(`ACTION ${lexerActionExecutor}`);
}
// seek to after last char in token
input.seek(index);
this._line = line;
this._charPositionInLine = charPos;
if (lexerActionExecutor != null && this.recog != null) {
lexerActionExecutor.execute(this.recog, input, startIndex);
}
}
getReachableTarget(trans, t) {
if (trans.matches(t, Lexer_1.Lexer.MIN_CHAR_VALUE, Lexer_1.Lexer.MAX_CHAR_VALUE)) {
return trans.target;
}
return undefined;
}
computeStartState(input, p) {
let initialContext = PredictionContext_1.PredictionContext.EMPTY_FULL;
let configs = new OrderedATNConfigSet_1.OrderedATNConfigSet();
for (let i = 0; i < p.numberOfTransitions; i++) {
let target = p.transition(i).target;
let c = ATNConfig_1.ATNConfig.create(target, i + 1, initialContext);
this.closure(input, c, configs, false, false, false);
}
return configs;
}
/**
* Since the alternatives within any lexer decision are ordered by
* preference, this method stops pursuing the closure as soon as an accept
* state is reached. After the first accept state is reached by depth-first
* search from `config`, all other (potentially reachable) states for
* this rule would have a lower priority.
*
* @returns `true` if an accept state is reached, otherwise
* `false`.
*/
closure(input, config, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon) {
if (LexerATNSimulator.debug) {
console.log("closure(" + config.toString(this.recog, true) + ")");
}
if (config.state instanceof RuleStopState_1.RuleStopState) {
if (LexerATNSimulator.debug) {
if (this.recog != null) {
console.log(`closure at ${this.recog.ruleNames[config.state.ruleIndex]} rule stop ${config}`);
}
else {
console.log(`closure at rule stop ${config}`);
}
}
let context = config.context;
if (context.isEmpty) {
configs.add(config);
return true;
}
else if (context.hasEmpty) {
configs.add(config.transform(config.state, true, PredictionContext_1.PredictionContext.EMPTY_FULL));
currentAltReachedAcceptState = true;
}
for (let i = 0; i < context.size; i++) {
let returnStateNumber = context.getReturnState(i);
if (returnStateNumber === PredictionContext_1.PredictionContext.EMPTY_FULL_STATE_KEY) {
continue;
}
let newContext = context.getParent(i); // "pop" return state
let returnState = this.atn.states[returnStateNumber];
let c = config.transform(returnState, false, newContext);
currentAltReachedAcceptState = this.closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
}
return currentAltReachedAcceptState;
}
// optimization
if (!config.state.onlyHasEpsilonTransitions) {
if (!currentAltReachedAcceptState || !config.hasPassedThroughNonGreedyDecision) {
configs.add(config);
}
}
let p = config.state;
for (let i = 0; i < p.numberOfOptimizedTransitions; i++) {
let t = p.getOptimizedTransition(i);
let c = this.getEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon);
if (c != null) {
currentAltReachedAcceptState = this.closure(input, c, configs, currentAltReachedAcceptState, speculative, treatEofAsEpsilon);
}
}
return currentAltReachedAcceptState;
}
// side-effect: can alter configs.hasSemanticContext
getEpsilonTarget(input, config, t, configs, speculative, treatEofAsEpsilon) {
let c;
switch (t.serializationType) {
case 3 /* RULE */:
let ruleTransition = t;
if (this.optimize_tail_calls && ruleTransition.optimizedTailCall && !config.context.hasEmpty) {
c = config.transform(t.target, true);
}
else {
let newContext = config.context.getChild(ruleTransition.followState.stateNumber);
c = config.transform(t.target, true, newContext);
}
break;
case 10 /* PRECEDENCE */:
throw new Error("Precedence predicates are not supported in lexers.");
case 4 /* PREDICATE */:
/* Track traversing semantic predicates. If we traverse,
we cannot add a DFA state for this "reach" computation
because the DFA would not test the predicate again in the
future. Rather than creating collections of semantic predicates
like v3 and testing them on prediction, v4 will test them on the
fly all the time using the ATN not the DFA. This is slower but
semantically it's not used that often. One of the key elements to
this predicate mechanism is not adding DFA states that see
predicates immediately afterwards in the ATN. For example,
a : ID {p1}? | ID {p2}? ;
should create the start state for rule 'a' (to save start state
competition), but should not create target of ID state. The
collection of ATN states the following ID references includes
states reached by traversing predicates. Since this is when we
test them, we cannot cash the DFA state target of ID.
*/
let pt = t;
if (LexerATNSimulator.debug) {
console.log("EVAL rule " + pt.ruleIndex + ":" + pt.predIndex);
}
configs.hasSemanticContext = true;
if (this.evaluatePredicate(input, pt.ruleIndex, pt.predIndex, speculative)) {
c = config.transform(t.target, true);
}
else {
c = undefined;
}
break;
case 6 /* ACTION */:
if (config.context.hasEmpty) {
// execute actions anywhere in the start rule for a token.
//
// TODO: if the entry rule is invoked recursively, some
// actions may be executed during the recursive call. The
// problem can appear when hasEmpty is true but
// isEmpty is false. In this case, the config needs to be
// split into two contexts - one with just the empty path
// and another with everything but the empty path.
// Unfortunately, the current algorithm does not allow
// getEpsilonTarget to return two configurations, so
// additional modifications are needed before we can support
// the split operation.
let lexerActionExecutor = LexerActionExecutor_1.LexerActionExecutor.append(config.lexerActionExecutor, this.atn.lexerActions[t.actionIndex]);
c = config.transform(t.target, true, lexerActionExecutor);
break;
}
else {
// ignore actions in referenced rules
c = config.transform(t.target, true);
break;
}
case 1 /* EPSILON */:
c = config.transform(t.target, true);
break;
case 5 /* ATOM */:
case 2 /* RANGE */:
case 7 /* SET */:
if (treatEofAsEpsilon) {
if (t.matches(IntStream_1.IntStream.EOF, Lexer_1.Lexer.MIN_CHAR_VALUE, Lexer_1.Lexer.MAX_CHAR_VALUE)) {
c = config.transform(t.target, false);
break;
}
}
c = undefined;
break;
default:
c = undefined;
break;
}
return c;
}
/**
* Evaluate a predicate specified in the lexer.
*
* If `speculative` is `true`, this method was called before
* {@link #consume} for the matched character. This method should call
* {@link #consume} before evaluating the predicate to ensure position
* sensitive values, including {@link Lexer#getText}, {@link Lexer#getLine},
* and {@link Lexer#getCharPositionInLine}, properly reflect the current
* lexer state. This method should restore `input` and the simulator
* to the original state before returning (i.e. undo the actions made by the
* call to {@link #consume}.
*
* @param input The input stream.
* @param ruleIndex The rule containing the predicate.
* @param predIndex The index of the predicate within the rule.
* @param speculative `true` if the current index in `input` is
* one character before the predicate's location.
*
* @returns `true` if the specified predicate evaluates to
* `true`.
*/
evaluatePredicate(input, ruleIndex, predIndex, speculative) {
// assume true if no recognizer was provided
if (this.recog == null) {
return true;
}
if (!speculative) {
return this.recog.sempred(undefined, ruleIndex, predIndex);
}
let savedCharPositionInLine = this._charPositionInLine;
let savedLine = this._line;
let index = input.index;
let marker = input.mark();
try {
this.consume(input);
return this.recog.sempred(undefined, ruleIndex, predIndex);
}
finally {
this._charPositionInLine = savedCharPositionInLine;
this._line = savedLine;
input.seek(index);
input.release(marker);
}
}
captureSimState(settings, input, dfaState) {
settings.index = input.index;
settings.line = this._line;
settings.charPos = this._charPositionInLine;
settings.dfaState = dfaState;
}
addDFAEdge(p, t, q) {
if (q instanceof ATNConfigSet_1.ATNConfigSet) {
/* leading to this call, ATNConfigSet.hasSemanticContext is used as a
* marker indicating dynamic predicate evaluation makes this edge
* dependent on the specific input sequence, so the static edge in the
* DFA should be omitted. The target DFAState is still created since
* execATN has the ability to resynchronize with the DFA state cache
* following the predicate evaluation step.
*
* TJP notes: next time through the DFA, we see a pred again and eval.
* If that gets us to a previously created (but dangling) DFA
* state, we can continue in pure DFA mode from there.
*/
let suppressEdge = q.hasSemanticContext;
if (suppressEdge) {
q.hasSemanticContext = false;
}
// @NotNull
let to = this.addDFAState(q);
if (suppressEdge) {
return to;
}
this.addDFAEdge(p, t, to);
return to;
}
else {
if (LexerATNSimulator.debug) {
console.log("EDGE " + p + " -> " + q + " upon " + String.fromCharCode(t));
}
if (p != null) {
p.setTarget(t, q);
}
}
}
/** Add a new DFA state if there isn't one with this set of
* configurations already. This method also detects the first
* configuration containing an ATN rule stop state. Later, when
* traversing the DFA, we will know which rule to accept.
*/
addDFAState(configs) {
/* the lexer evaluates predicates on-the-fly; by this point configs
* should not contain any configurations with unevaluated predicates.
*/
assert(!configs.hasSemanticContext);
let proposed = new DFAState_1.DFAState(configs);
let existing = this.atn.modeToDFA[this.mode].states.get(proposed);
if (existing != null) {
return existing;
}
configs.optimizeConfigs(this);
let newState = new DFAState_1.DFAState(configs.clone(true));
let firstConfigWithRuleStopState;
for (let c of configs) {
if (c.state instanceof RuleStopState_1.RuleStopState) {
firstConfigWithRuleStopState = c;
break;
}
}
if (firstConfigWithRuleStopState != null) {
let prediction = this.atn.ruleToTokenType[firstConfigWithRuleStopState.state.ruleIndex];
let lexerActionExecutor = firstConfigWithRuleStopState.lexerActionExecutor;
newState.acceptStateInfo = new AcceptStateInfo_1.AcceptStateInfo(prediction, lexerActionExecutor);
}
return this.atn.modeToDFA[this.mode].addState(newState);
}
getDFA(mode) {
return this.atn.modeToDFA[mode];
}
/** Get the text matched so far for the current token.
*/
getText(input) {
// index is first lookahead char, don't include.
return input.getText(Interval_1.Interval.of(this.startIndex, input.index - 1));
}
get line() {
return this._line;
}
set line(line) {
this._line = line;
}
get charPositionInLine() {
return this._charPositionInLine;
}
set charPositionInLine(charPositionInLine) {
this._charPositionInLine = charPositionInLine;
}
consume(input) {
let curChar = input.LA(1);
if (curChar === "\n".charCodeAt(0)) {
this._line++;
this._charPositionInLine = 0;
}
else {
this._charPositionInLine++;
}
input.consume();
}
getTokenName(t) {
if (t === -1) {
return "EOF";
}
//if ( atn.g!=null ) return atn.g.getTokenDisplayName(t);
return "'" + String.fromCharCode(t) + "'";
}
};
__decorate([
Decorators_1.NotNull
], LexerATNSimulator.prototype, "prevAccept", void 0);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "copyState", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "match", null);
__decorate([
Decorators_1.Override
], LexerATNSimulator.prototype, "reset", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "matchATN", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "execATN", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "getExistingTargetState", null);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "computeTargetState", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "getReachableConfigSet", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "accept", null);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull),
__param(1, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "computeStartState", null);
__decorate([
__param(0, Decorators_1.NotNull), __param(1, Decorators_1.NotNull), __param(2, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "closure", null);
__decorate([
__param(0, Decorators_1.NotNull),
__param(1, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull),
__param(3, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "getEpsilonTarget", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "evaluatePredicate", null);
__decorate([
__param(0, Decorators_1.NotNull),
__param(1, Decorators_1.NotNull),
__param(2, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "captureSimState", null);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "addDFAState", null);
__decorate([
Decorators_1.NotNull
], LexerATNSimulator.prototype, "getDFA", null);
__decorate([
Decorators_1.NotNull,
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "getText", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator.prototype, "consume", null);
__decorate([
Decorators_1.NotNull
], LexerATNSimulator.prototype, "getTokenName", null);
LexerATNSimulator = __decorate([
__param(0, Decorators_1.NotNull)
], LexerATNSimulator);
exports.LexerATNSimulator = LexerATNSimulator;
(function (LexerATNSimulator) {
LexerATNSimulator.debug = false;
LexerATNSimulator.dfa_debug = false;
/** When we hit an accept state in either the DFA or the ATN, we
* have to notify the character stream to start buffering characters
* via {@link IntStream#mark} and record the current state. The current sim state
* includes the current index into the input, the current line,
* and current character position in that line. Note that the Lexer is
* tracking the starting line and characterization of the token. These
* variables track the "state" of the simulator when it hits an accept state.
*
* We track these variables separately for the DFA and ATN simulation
* because the DFA simulation often has to fail over to the ATN
* simulation. If the ATN simulation fails, we need the DFA to fall
* back to its previously accepted state, if any. If the ATN succeeds,
* then the ATN does the accept and the DFA simulator that invoked it
* can simply return the predicted token type.
*/
class SimState {
constructor() {
this.index = -1;
this.line = 0;
this.charPos = -1;
}
reset() {
this.index = -1;
this.line = 0;
this.charPos = -1;
this.dfaState = undefined;
}
}
LexerATNSimulator.SimState = SimState;
})(LexerATNSimulator = exports.LexerATNSimulator || (exports.LexerATNSimulator = {}));
exports.LexerATNSimulator = LexerATNSimulator;
//# sourceMappingURL=LexerATNSimulator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Equatable } from "../misc/Stubs";
import { Lexer } from "../Lexer";
import { LexerActionType } from "./LexerActionType";
/**
* Represents a single action which can be executed following the successful
* match of a lexer rule. Lexer actions are used for both embedded action syntax
* and ANTLR 4's new lexer command syntax.
*
* @author Sam Harwell
* @since 4.2
*/
export interface LexerAction extends Equatable {
/**
* Gets the serialization type of the lexer action.
*
* @returns The serialization type of the lexer action.
*/
readonly actionType: LexerActionType;
/**
* Gets whether the lexer action is position-dependent. Position-dependent
* actions may have different semantics depending on the {@link CharStream}
* index at the time the action is executed.
*
* Many lexer commands, including `type`, `skip`, and
* `more`, do not check the input index during their execution.
* Actions like this are position-independent, and may be stored more
* efficiently as part of the `ATNConfig.lexerActionExecutor`.
*
* @returns `true` if the lexer action semantics can be affected by the
* position of the input {@link CharStream} at the time it is executed;
* otherwise, `false`.
*/
readonly isPositionDependent: boolean;
/**
* Execute the lexer action in the context of the specified {@link Lexer}.
*
* For position-dependent actions, the input stream must already be
* positioned correctly prior to calling this method.
*
* @param lexer The lexer instance.
*/
execute(/*@NotNull*/ lexer: Lexer): void;
}

View File

@@ -0,0 +1,7 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=LexerAction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LexerAction.js","sourceRoot":"","sources":["../../../src/atn/LexerAction.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:28.7973969-07:00\r\n\r\nimport { Equatable } from \"../misc/Stubs\";\r\nimport { Lexer } from \"../Lexer\";\r\nimport { LexerActionType } from \"./LexerActionType\";\r\n\r\n/**\r\n * Represents a single action which can be executed following the successful\r\n * match of a lexer rule. Lexer actions are used for both embedded action syntax\r\n * and ANTLR 4's new lexer command syntax.\r\n *\r\n * @author Sam Harwell\r\n * @since 4.2\r\n */\r\nexport interface LexerAction extends Equatable {\r\n\t/**\r\n\t * Gets the serialization type of the lexer action.\r\n\t *\r\n\t * @returns The serialization type of the lexer action.\r\n\t */\r\n\t//@NotNull\r\n\treadonly actionType: LexerActionType;\r\n\r\n\t/**\r\n\t * Gets whether the lexer action is position-dependent. Position-dependent\r\n\t * actions may have different semantics depending on the {@link CharStream}\r\n\t * index at the time the action is executed.\r\n\t *\r\n\t * Many lexer commands, including `type`, `skip`, and\r\n\t * `more`, do not check the input index during their execution.\r\n\t * Actions like this are position-independent, and may be stored more\r\n\t * efficiently as part of the `ATNConfig.lexerActionExecutor`.\r\n\t *\r\n\t * @returns `true` if the lexer action semantics can be affected by the\r\n\t * position of the input {@link CharStream} at the time it is executed;\r\n\t * otherwise, `false`.\r\n\t */\r\n\treadonly isPositionDependent: boolean;\r\n\r\n\t/**\r\n\t * Execute the lexer action in the context of the specified {@link Lexer}.\r\n\t *\r\n\t * For position-dependent actions, the input stream must already be\r\n\t * positioned correctly prior to calling this method.\r\n\t *\r\n\t * @param lexer The lexer instance.\r\n\t */\r\n\texecute(/*@NotNull*/ lexer: Lexer): void;\r\n}\r\n"]}

View File

@@ -0,0 +1,104 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { CharStream } from "../CharStream";
import { Lexer } from "../Lexer";
import { LexerAction } from "./LexerAction";
/**
* Represents an executor for a sequence of lexer actions which traversed during
* the matching operation of a lexer rule (token).
*
* The executor tracks position information for position-dependent lexer actions
* efficiently, ensuring that actions appearing only at the end of the rule do
* not cause bloating of the {@link DFA} created for the lexer.
*
* @author Sam Harwell
* @since 4.2
*/
export declare class LexerActionExecutor {
private _lexerActions;
/**
* Caches the result of {@link #hashCode} since the hash code is an element
* of the performance-critical {@link LexerATNConfig#hashCode} operation.
*/
private cachedHashCode;
/**
* Constructs an executor for a sequence of {@link LexerAction} actions.
* @param lexerActions The lexer actions to execute.
*/
constructor(lexerActions: LexerAction[]);
/**
* Creates a {@link LexerActionExecutor} which executes the actions for
* the input `lexerActionExecutor` followed by a specified
* `lexerAction`.
*
* @param lexerActionExecutor The executor for actions already traversed by
* the lexer while matching a token within a particular
* {@link ATNConfig}. If this is `undefined`, the method behaves as though
* it were an empty executor.
* @param lexerAction The lexer action to execute after the actions
* specified in `lexerActionExecutor`.
*
* @returns A {@link LexerActionExecutor} for executing the combine actions
* of `lexerActionExecutor` and `lexerAction`.
*/
static append(lexerActionExecutor: LexerActionExecutor | undefined, lexerAction: LexerAction): LexerActionExecutor;
/**
* Creates a {@link LexerActionExecutor} which encodes the current offset
* for position-dependent lexer actions.
*
* Normally, when the executor encounters lexer actions where
* {@link LexerAction#isPositionDependent} returns `true`, it calls
* {@link IntStream#seek} on the input {@link CharStream} to set the input
* position to the *end* of the current token. This behavior provides
* for efficient DFA representation of lexer actions which appear at the end
* of a lexer rule, even when the lexer rule matches a variable number of
* characters.
*
* Prior to traversing a match transition in the ATN, the current offset
* from the token start index is assigned to all position-dependent lexer
* actions which have not already been assigned a fixed offset. By storing
* the offsets relative to the token start index, the DFA representation of
* lexer actions which appear in the middle of tokens remains efficient due
* to sharing among tokens of the same length, regardless of their absolute
* position in the input stream.
*
* If the current executor already has offsets assigned to all
* position-dependent lexer actions, the method returns `this`.
*
* @param offset The current offset to assign to all position-dependent
* lexer actions which do not already have offsets assigned.
*
* @returns A {@link LexerActionExecutor} which stores input stream offsets
* for all position-dependent lexer actions.
*/
fixOffsetBeforeMatch(offset: number): LexerActionExecutor;
/**
* Gets the lexer actions to be executed by this executor.
* @returns The lexer actions to be executed by this executor.
*/
get lexerActions(): LexerAction[];
/**
* Execute the actions encapsulated by this executor within the context of a
* particular {@link Lexer}.
*
* This method calls {@link IntStream#seek} to set the position of the
* `input` {@link CharStream} prior to calling
* {@link LexerAction#execute} on a position-dependent action. Before the
* method returns, the input position will be restored to the same position
* it was in when the method was invoked.
*
* @param lexer The lexer instance.
* @param input The input stream which is the source for the current token.
* When this method is called, the current {@link IntStream#index} for
* `input` should be the start of the following token, i.e. 1
* character past the end of the current token.
* @param startIndex The token start index. This value may be passed to
* {@link IntStream#seek} to set the `input` position to the beginning
* of the token.
*/
execute(lexer: Lexer, input: CharStream, startIndex: number): void;
hashCode(): number;
equals(obj: any): boolean;
}

View File

@@ -0,0 +1,200 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexerActionExecutor = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:28.8810453-07:00
const ArrayEqualityComparator_1 = require("../misc/ArrayEqualityComparator");
const LexerIndexedCustomAction_1 = require("./LexerIndexedCustomAction");
const MurmurHash_1 = require("../misc/MurmurHash");
const Decorators_1 = require("../Decorators");
/**
* Represents an executor for a sequence of lexer actions which traversed during
* the matching operation of a lexer rule (token).
*
* The executor tracks position information for position-dependent lexer actions
* efficiently, ensuring that actions appearing only at the end of the rule do
* not cause bloating of the {@link DFA} created for the lexer.
*
* @author Sam Harwell
* @since 4.2
*/
let LexerActionExecutor = class LexerActionExecutor {
/**
* Constructs an executor for a sequence of {@link LexerAction} actions.
* @param lexerActions The lexer actions to execute.
*/
constructor(lexerActions) {
this._lexerActions = lexerActions;
let hash = MurmurHash_1.MurmurHash.initialize();
for (let lexerAction of lexerActions) {
hash = MurmurHash_1.MurmurHash.update(hash, lexerAction);
}
this.cachedHashCode = MurmurHash_1.MurmurHash.finish(hash, lexerActions.length);
}
/**
* Creates a {@link LexerActionExecutor} which executes the actions for
* the input `lexerActionExecutor` followed by a specified
* `lexerAction`.
*
* @param lexerActionExecutor The executor for actions already traversed by
* the lexer while matching a token within a particular
* {@link ATNConfig}. If this is `undefined`, the method behaves as though
* it were an empty executor.
* @param lexerAction The lexer action to execute after the actions
* specified in `lexerActionExecutor`.
*
* @returns A {@link LexerActionExecutor} for executing the combine actions
* of `lexerActionExecutor` and `lexerAction`.
*/
static append(lexerActionExecutor, lexerAction) {
if (!lexerActionExecutor) {
return new LexerActionExecutor([lexerAction]);
}
let lexerActions = lexerActionExecutor._lexerActions.slice(0);
lexerActions.push(lexerAction);
return new LexerActionExecutor(lexerActions);
}
/**
* Creates a {@link LexerActionExecutor} which encodes the current offset
* for position-dependent lexer actions.
*
* Normally, when the executor encounters lexer actions where
* {@link LexerAction#isPositionDependent} returns `true`, it calls
* {@link IntStream#seek} on the input {@link CharStream} to set the input
* position to the *end* of the current token. This behavior provides
* for efficient DFA representation of lexer actions which appear at the end
* of a lexer rule, even when the lexer rule matches a variable number of
* characters.
*
* Prior to traversing a match transition in the ATN, the current offset
* from the token start index is assigned to all position-dependent lexer
* actions which have not already been assigned a fixed offset. By storing
* the offsets relative to the token start index, the DFA representation of
* lexer actions which appear in the middle of tokens remains efficient due
* to sharing among tokens of the same length, regardless of their absolute
* position in the input stream.
*
* If the current executor already has offsets assigned to all
* position-dependent lexer actions, the method returns `this`.
*
* @param offset The current offset to assign to all position-dependent
* lexer actions which do not already have offsets assigned.
*
* @returns A {@link LexerActionExecutor} which stores input stream offsets
* for all position-dependent lexer actions.
*/
fixOffsetBeforeMatch(offset) {
let updatedLexerActions;
for (let i = 0; i < this._lexerActions.length; i++) {
if (this._lexerActions[i].isPositionDependent && !(this._lexerActions[i] instanceof LexerIndexedCustomAction_1.LexerIndexedCustomAction)) {
if (!updatedLexerActions) {
updatedLexerActions = this._lexerActions.slice(0);
}
updatedLexerActions[i] = new LexerIndexedCustomAction_1.LexerIndexedCustomAction(offset, this._lexerActions[i]);
}
}
if (!updatedLexerActions) {
return this;
}
return new LexerActionExecutor(updatedLexerActions);
}
/**
* Gets the lexer actions to be executed by this executor.
* @returns The lexer actions to be executed by this executor.
*/
get lexerActions() {
return this._lexerActions;
}
/**
* Execute the actions encapsulated by this executor within the context of a
* particular {@link Lexer}.
*
* This method calls {@link IntStream#seek} to set the position of the
* `input` {@link CharStream} prior to calling
* {@link LexerAction#execute} on a position-dependent action. Before the
* method returns, the input position will be restored to the same position
* it was in when the method was invoked.
*
* @param lexer The lexer instance.
* @param input The input stream which is the source for the current token.
* When this method is called, the current {@link IntStream#index} for
* `input` should be the start of the following token, i.e. 1
* character past the end of the current token.
* @param startIndex The token start index. This value may be passed to
* {@link IntStream#seek} to set the `input` position to the beginning
* of the token.
*/
execute(lexer, input, startIndex) {
let requiresSeek = false;
let stopIndex = input.index;
try {
for (let lexerAction of this._lexerActions) {
if (lexerAction instanceof LexerIndexedCustomAction_1.LexerIndexedCustomAction) {
let offset = lexerAction.offset;
input.seek(startIndex + offset);
lexerAction = lexerAction.action;
requiresSeek = (startIndex + offset) !== stopIndex;
}
else if (lexerAction.isPositionDependent) {
input.seek(stopIndex);
requiresSeek = false;
}
lexerAction.execute(lexer);
}
}
finally {
if (requiresSeek) {
input.seek(stopIndex);
}
}
}
hashCode() {
return this.cachedHashCode;
}
equals(obj) {
if (obj === this) {
return true;
}
else if (!(obj instanceof LexerActionExecutor)) {
return false;
}
return this.cachedHashCode === obj.cachedHashCode
&& ArrayEqualityComparator_1.ArrayEqualityComparator.INSTANCE.equals(this._lexerActions, obj._lexerActions);
}
};
__decorate([
Decorators_1.NotNull
], LexerActionExecutor.prototype, "_lexerActions", void 0);
__decorate([
Decorators_1.NotNull
], LexerActionExecutor.prototype, "lexerActions", null);
__decorate([
__param(0, Decorators_1.NotNull)
], LexerActionExecutor.prototype, "execute", null);
__decorate([
Decorators_1.Override
], LexerActionExecutor.prototype, "hashCode", null);
__decorate([
Decorators_1.Override
], LexerActionExecutor.prototype, "equals", null);
__decorate([
Decorators_1.NotNull,
__param(1, Decorators_1.NotNull)
], LexerActionExecutor, "append", null);
LexerActionExecutor = __decorate([
__param(0, Decorators_1.NotNull)
], LexerActionExecutor);
exports.LexerActionExecutor = LexerActionExecutor;
//# sourceMappingURL=LexerActionExecutor.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,44 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
/**
* Represents the serialization type of a {@link LexerAction}.
*
* @author Sam Harwell
* @since 4.2
*/
export declare const enum LexerActionType {
/**
* The type of a {@link LexerChannelAction} action.
*/
CHANNEL = 0,
/**
* The type of a {@link LexerCustomAction} action.
*/
CUSTOM = 1,
/**
* The type of a {@link LexerModeAction} action.
*/
MODE = 2,
/**
* The type of a {@link LexerMoreAction} action.
*/
MORE = 3,
/**
* The type of a {@link LexerPopModeAction} action.
*/
POP_MODE = 4,
/**
* The type of a {@link LexerPushModeAction} action.
*/
PUSH_MODE = 5,
/**
* The type of a {@link LexerSkipAction} action.
*/
SKIP = 6,
/**
* The type of a {@link LexerTypeAction} action.
*/
TYPE = 7
}

View File

@@ -0,0 +1,50 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexerActionType = void 0;
// ConvertTo-TS run at 2016-10-04T11:26:29.0172086-07:00
/**
* Represents the serialization type of a {@link LexerAction}.
*
* @author Sam Harwell
* @since 4.2
*/
var LexerActionType;
(function (LexerActionType) {
/**
* The type of a {@link LexerChannelAction} action.
*/
LexerActionType[LexerActionType["CHANNEL"] = 0] = "CHANNEL";
/**
* The type of a {@link LexerCustomAction} action.
*/
LexerActionType[LexerActionType["CUSTOM"] = 1] = "CUSTOM";
/**
* The type of a {@link LexerModeAction} action.
*/
LexerActionType[LexerActionType["MODE"] = 2] = "MODE";
/**
* The type of a {@link LexerMoreAction} action.
*/
LexerActionType[LexerActionType["MORE"] = 3] = "MORE";
/**
* The type of a {@link LexerPopModeAction} action.
*/
LexerActionType[LexerActionType["POP_MODE"] = 4] = "POP_MODE";
/**
* The type of a {@link LexerPushModeAction} action.
*/
LexerActionType[LexerActionType["PUSH_MODE"] = 5] = "PUSH_MODE";
/**
* The type of a {@link LexerSkipAction} action.
*/
LexerActionType[LexerActionType["SKIP"] = 6] = "SKIP";
/**
* The type of a {@link LexerTypeAction} action.
*/
LexerActionType[LexerActionType["TYPE"] = 7] = "TYPE";
})(LexerActionType = exports.LexerActionType || (exports.LexerActionType = {}));
//# sourceMappingURL=LexerActionType.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LexerActionType.js","sourceRoot":"","sources":["../../../src/atn/LexerActionType.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,wDAAwD;AAExD;;;;;GAKG;AACH,IAAkB,eAiCjB;AAjCD,WAAkB,eAAe;IAChC;;OAEG;IACH,2DAAO,CAAA;IACP;;OAEG;IACH,yDAAM,CAAA;IACN;;OAEG;IACH,qDAAI,CAAA;IACJ;;OAEG;IACH,qDAAI,CAAA;IACJ;;OAEG;IACH,6DAAQ,CAAA;IACR;;OAEG;IACH,+DAAS,CAAA;IACT;;OAEG;IACH,qDAAI,CAAA;IACJ;;OAEG;IACH,qDAAI,CAAA;AACL,CAAC,EAjCiB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAiChC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:29.0172086-07:00\r\n\r\n/**\r\n * Represents the serialization type of a {@link LexerAction}.\r\n *\r\n * @author Sam Harwell\r\n * @since 4.2\r\n */\r\nexport const enum LexerActionType {\r\n\t/**\r\n\t * The type of a {@link LexerChannelAction} action.\r\n\t */\r\n\tCHANNEL,\r\n\t/**\r\n\t * The type of a {@link LexerCustomAction} action.\r\n\t */\r\n\tCUSTOM,\r\n\t/**\r\n\t * The type of a {@link LexerModeAction} action.\r\n\t */\r\n\tMODE,\r\n\t/**\r\n\t * The type of a {@link LexerMoreAction} action.\r\n\t */\r\n\tMORE,\r\n\t/**\r\n\t * The type of a {@link LexerPopModeAction} action.\r\n\t */\r\n\tPOP_MODE,\r\n\t/**\r\n\t * The type of a {@link LexerPushModeAction} action.\r\n\t */\r\n\tPUSH_MODE,\r\n\t/**\r\n\t * The type of a {@link LexerSkipAction} action.\r\n\t */\r\n\tSKIP,\r\n\t/**\r\n\t * The type of a {@link LexerTypeAction} action.\r\n\t */\r\n\tTYPE,\r\n}\r\n"]}

View File

@@ -0,0 +1,48 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Lexer } from "../Lexer";
import { LexerAction } from "./LexerAction";
import { LexerActionType } from "./LexerActionType";
/**
* Implements the `channel` lexer action by calling
* {@link Lexer#setChannel} with the assigned channel.
*
* @author Sam Harwell
* @since 4.2
*/
export declare class LexerChannelAction implements LexerAction {
private readonly _channel;
/**
* Constructs a new `channel` action with the specified channel value.
* @param channel The channel value to pass to {@link Lexer#setChannel}.
*/
constructor(channel: number);
/**
* Gets the channel to use for the {@link Token} created by the lexer.
*
* @returns The channel to use for the {@link Token} created by the lexer.
*/
get channel(): number;
/**
* {@inheritDoc}
* @returns This method returns {@link LexerActionType#CHANNEL}.
*/
get actionType(): LexerActionType;
/**
* {@inheritDoc}
* @returns This method returns `false`.
*/
get isPositionDependent(): boolean;
/**
* {@inheritDoc}
*
* This action is implemented by calling {@link Lexer#setChannel} with the
* value provided by {@link #getChannel}.
*/
execute(lexer: Lexer): void;
hashCode(): number;
equals(obj: any): boolean;
toString(): string;
}

View File

@@ -0,0 +1,104 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexerChannelAction = void 0;
const MurmurHash_1 = require("../misc/MurmurHash");
const Decorators_1 = require("../Decorators");
/**
* Implements the `channel` lexer action by calling
* {@link Lexer#setChannel} with the assigned channel.
*
* @author Sam Harwell
* @since 4.2
*/
class LexerChannelAction {
/**
* Constructs a new `channel` action with the specified channel value.
* @param channel The channel value to pass to {@link Lexer#setChannel}.
*/
constructor(channel) {
this._channel = channel;
}
/**
* Gets the channel to use for the {@link Token} created by the lexer.
*
* @returns The channel to use for the {@link Token} created by the lexer.
*/
get channel() {
return this._channel;
}
/**
* {@inheritDoc}
* @returns This method returns {@link LexerActionType#CHANNEL}.
*/
get actionType() {
return 0 /* CHANNEL */;
}
/**
* {@inheritDoc}
* @returns This method returns `false`.
*/
get isPositionDependent() {
return false;
}
/**
* {@inheritDoc}
*
* This action is implemented by calling {@link Lexer#setChannel} with the
* value provided by {@link #getChannel}.
*/
execute(lexer) {
lexer.channel = this._channel;
}
hashCode() {
let hash = MurmurHash_1.MurmurHash.initialize();
hash = MurmurHash_1.MurmurHash.update(hash, this.actionType);
hash = MurmurHash_1.MurmurHash.update(hash, this._channel);
return MurmurHash_1.MurmurHash.finish(hash, 2);
}
equals(obj) {
if (obj === this) {
return true;
}
else if (!(obj instanceof LexerChannelAction)) {
return false;
}
return this._channel === obj._channel;
}
toString() {
return `channel(${this._channel})`;
}
}
__decorate([
Decorators_1.Override
], LexerChannelAction.prototype, "actionType", null);
__decorate([
Decorators_1.Override
], LexerChannelAction.prototype, "isPositionDependent", null);
__decorate([
Decorators_1.Override,
__param(0, Decorators_1.NotNull)
], LexerChannelAction.prototype, "execute", null);
__decorate([
Decorators_1.Override
], LexerChannelAction.prototype, "hashCode", null);
__decorate([
Decorators_1.Override
], LexerChannelAction.prototype, "equals", null);
__decorate([
Decorators_1.Override
], LexerChannelAction.prototype, "toString", null);
exports.LexerChannelAction = LexerChannelAction;
//# sourceMappingURL=LexerChannelAction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LexerChannelAction.js","sourceRoot":"","sources":["../../../src/atn/LexerChannelAction.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAOH,mDAAgD;AAChD,8CAAkD;AAElD;;;;;;GAMG;AACH,MAAa,kBAAkB;IAG9B;;;OAGG;IACH,YAAY,OAAe;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED;;;OAGG;IAEH,IAAI,UAAU;QACb,uBAA+B;IAChC,CAAC;IAED;;;OAGG;IAEH,IAAI,mBAAmB;QACtB,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IAEI,OAAO,CAAU,KAAY;QACnC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAGM,QAAQ;QACd,IAAI,IAAI,GAAW,uBAAU,CAAC,UAAU,EAAE,CAAC;QAC3C,IAAI,GAAG,uBAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,GAAG,uBAAU,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,uBAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAGM,MAAM,CAAC,GAAQ;QACrB,IAAI,GAAG,KAAK,IAAI,EAAE;YACjB,OAAO,IAAI,CAAC;SACZ;aAAM,IAAI,CAAC,CAAC,GAAG,YAAY,kBAAkB,CAAC,EAAE;YAChD,OAAO,KAAK,CAAC;SACb;QAED,OAAO,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC,QAAQ,CAAC;IACvC,CAAC;IAGM,QAAQ;QACd,OAAO,WAAW,IAAI,CAAC,QAAQ,GAAG,CAAC;IACpC,CAAC;CACD;AA/CA;IADC,qBAAQ;oDAGR;AAOD;IADC,qBAAQ;6DAGR;AASD;IADC,qBAAQ;IACO,WAAA,oBAAO,CAAA;iDAEtB;AAGD;IADC,qBAAQ;kDAMR;AAGD;IADC,qBAAQ;gDASR;AAGD;IADC,qBAAQ;kDAGR;AAvEF,gDAwEC","sourcesContent":["/*!\r\n * Copyright 2016 The ANTLR Project. All rights reserved.\r\n * Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.\r\n */\r\n\r\n// ConvertTo-TS run at 2016-10-04T11:26:29.5634388-07:00\r\n\r\nimport { Lexer } from \"../Lexer\";\r\nimport { LexerAction } from \"./LexerAction\";\r\nimport { LexerActionType } from \"./LexerActionType\";\r\nimport { MurmurHash } from \"../misc/MurmurHash\";\r\nimport { NotNull, Override } from \"../Decorators\";\r\n\r\n/**\r\n * Implements the `channel` lexer action by calling\r\n * {@link Lexer#setChannel} with the assigned channel.\r\n *\r\n * @author Sam Harwell\r\n * @since 4.2\r\n */\r\nexport class LexerChannelAction implements LexerAction {\r\n\tprivate readonly _channel: number;\r\n\r\n\t/**\r\n\t * Constructs a new `channel` action with the specified channel value.\r\n\t * @param channel The channel value to pass to {@link Lexer#setChannel}.\r\n\t */\r\n\tconstructor(channel: number) {\r\n\t\tthis._channel = channel;\r\n\t}\r\n\r\n\t/**\r\n\t * Gets the channel to use for the {@link Token} created by the lexer.\r\n\t *\r\n\t * @returns The channel to use for the {@link Token} created by the lexer.\r\n\t */\r\n\tget channel(): number {\r\n\t\treturn this._channel;\r\n\t}\r\n\r\n\t/**\r\n\t * {@inheritDoc}\r\n\t * @returns This method returns {@link LexerActionType#CHANNEL}.\r\n\t */\r\n\t@Override\r\n\tget actionType(): LexerActionType {\r\n\t\treturn LexerActionType.CHANNEL;\r\n\t}\r\n\r\n\t/**\r\n\t * {@inheritDoc}\r\n\t * @returns This method returns `false`.\r\n\t */\r\n\t@Override\r\n\tget isPositionDependent(): boolean {\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/**\r\n\t * {@inheritDoc}\r\n\t *\r\n\t * This action is implemented by calling {@link Lexer#setChannel} with the\r\n\t * value provided by {@link #getChannel}.\r\n\t */\r\n\t@Override\r\n\tpublic execute(@NotNull lexer: Lexer): void {\r\n\t\tlexer.channel = this._channel;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic hashCode(): number {\r\n\t\tlet hash: number = MurmurHash.initialize();\r\n\t\thash = MurmurHash.update(hash, this.actionType);\r\n\t\thash = MurmurHash.update(hash, this._channel);\r\n\t\treturn MurmurHash.finish(hash, 2);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic equals(obj: any): boolean {\r\n\t\tif (obj === this) {\r\n\t\t\treturn true;\r\n\t\t} else if (!(obj instanceof LexerChannelAction)) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\treturn this._channel === obj._channel;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic toString(): string {\r\n\t\treturn `channel(${this._channel})`;\r\n\t}\r\n}\r\n"]}

View File

@@ -0,0 +1,73 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Lexer } from "../Lexer";
import { LexerAction } from "./LexerAction";
import { LexerActionType } from "./LexerActionType";
/**
* Executes a custom lexer action by calling {@link Recognizer#action} with the
* rule and action indexes assigned to the custom action. The implementation of
* a custom action is added to the generated code for the lexer in an override
* of {@link Recognizer#action} when the grammar is compiled.
*
* This class may represent embedded actions created with the `{...}`
* syntax in ANTLR 4, as well as actions created for lexer commands where the
* command argument could not be evaluated when the grammar was compiled.
*
* @author Sam Harwell
* @since 4.2
*/
export declare class LexerCustomAction implements LexerAction {
private readonly _ruleIndex;
private readonly _actionIndex;
/**
* Constructs a custom lexer action with the specified rule and action
* indexes.
*
* @param ruleIndex The rule index to use for calls to
* {@link Recognizer#action}.
* @param actionIndex The action index to use for calls to
* {@link Recognizer#action}.
*/
constructor(ruleIndex: number, actionIndex: number);
/**
* Gets the rule index to use for calls to {@link Recognizer#action}.
*
* @returns The rule index for the custom action.
*/
get ruleIndex(): number;
/**
* Gets the action index to use for calls to {@link Recognizer#action}.
*
* @returns The action index for the custom action.
*/
get actionIndex(): number;
/**
* {@inheritDoc}
*
* @returns This method returns {@link LexerActionType#CUSTOM}.
*/
get actionType(): LexerActionType;
/**
* Gets whether the lexer action is position-dependent. Position-dependent
* actions may have different semantics depending on the {@link CharStream}
* index at the time the action is executed.
*
* Custom actions are position-dependent since they may represent a
* user-defined embedded action which makes calls to methods like
* {@link Lexer#getText}.
*
* @returns This method returns `true`.
*/
get isPositionDependent(): boolean;
/**
* {@inheritDoc}
*
* Custom actions are implemented by calling {@link Lexer#action} with the
* appropriate rule and action indexes.
*/
execute(lexer: Lexer): void;
hashCode(): number;
equals(obj: any): boolean;
}

View File

@@ -0,0 +1,128 @@
"use strict";
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LexerCustomAction = void 0;
const MurmurHash_1 = require("../misc/MurmurHash");
const Decorators_1 = require("../Decorators");
/**
* Executes a custom lexer action by calling {@link Recognizer#action} with the
* rule and action indexes assigned to the custom action. The implementation of
* a custom action is added to the generated code for the lexer in an override
* of {@link Recognizer#action} when the grammar is compiled.
*
* This class may represent embedded actions created with the `{...}`
* syntax in ANTLR 4, as well as actions created for lexer commands where the
* command argument could not be evaluated when the grammar was compiled.
*
* @author Sam Harwell
* @since 4.2
*/
class LexerCustomAction {
/**
* Constructs a custom lexer action with the specified rule and action
* indexes.
*
* @param ruleIndex The rule index to use for calls to
* {@link Recognizer#action}.
* @param actionIndex The action index to use for calls to
* {@link Recognizer#action}.
*/
constructor(ruleIndex, actionIndex) {
this._ruleIndex = ruleIndex;
this._actionIndex = actionIndex;
}
/**
* Gets the rule index to use for calls to {@link Recognizer#action}.
*
* @returns The rule index for the custom action.
*/
get ruleIndex() {
return this._ruleIndex;
}
/**
* Gets the action index to use for calls to {@link Recognizer#action}.
*
* @returns The action index for the custom action.
*/
get actionIndex() {
return this._actionIndex;
}
/**
* {@inheritDoc}
*
* @returns This method returns {@link LexerActionType#CUSTOM}.
*/
get actionType() {
return 1 /* CUSTOM */;
}
/**
* Gets whether the lexer action is position-dependent. Position-dependent
* actions may have different semantics depending on the {@link CharStream}
* index at the time the action is executed.
*
* Custom actions are position-dependent since they may represent a
* user-defined embedded action which makes calls to methods like
* {@link Lexer#getText}.
*
* @returns This method returns `true`.
*/
get isPositionDependent() {
return true;
}
/**
* {@inheritDoc}
*
* Custom actions are implemented by calling {@link Lexer#action} with the
* appropriate rule and action indexes.
*/
execute(lexer) {
lexer.action(undefined, this._ruleIndex, this._actionIndex);
}
hashCode() {
let hash = MurmurHash_1.MurmurHash.initialize();
hash = MurmurHash_1.MurmurHash.update(hash, this.actionType);
hash = MurmurHash_1.MurmurHash.update(hash, this._ruleIndex);
hash = MurmurHash_1.MurmurHash.update(hash, this._actionIndex);
return MurmurHash_1.MurmurHash.finish(hash, 3);
}
equals(obj) {
if (obj === this) {
return true;
}
else if (!(obj instanceof LexerCustomAction)) {
return false;
}
return this._ruleIndex === obj._ruleIndex
&& this._actionIndex === obj._actionIndex;
}
}
__decorate([
Decorators_1.Override
], LexerCustomAction.prototype, "actionType", null);
__decorate([
Decorators_1.Override
], LexerCustomAction.prototype, "isPositionDependent", null);
__decorate([
Decorators_1.Override,
__param(0, Decorators_1.NotNull)
], LexerCustomAction.prototype, "execute", null);
__decorate([
Decorators_1.Override
], LexerCustomAction.prototype, "hashCode", null);
__decorate([
Decorators_1.Override
], LexerCustomAction.prototype, "equals", null);
exports.LexerCustomAction = LexerCustomAction;
//# sourceMappingURL=LexerCustomAction.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
/*!
* Copyright 2016 The ANTLR Project. All rights reserved.
* Licensed under the BSD-3-Clause license. See LICENSE file in the project root for license information.
*/
import { Lexer } from "../Lexer";
import { LexerAction } from "./LexerAction";
import { LexerActionType } from "./LexerActionType";
/**
* This implementation of {@link LexerAction} is used for tracking input offsets
* for position-dependent actions within a {@link LexerActionExecutor}.
*
* This action is not serialized as part of the ATN, and is only required for
* position-dependent lexer actions which appear at a location other than the
* end of a rule. For more information about DFA optimizations employed for
* lexer actions, see {@link LexerActionExecutor#append} and
* {@link LexerActionExecutor#fixOffsetBeforeMatch}.
*
* @author Sam Harwell
* @since 4.2
*/
export declare class LexerIndexedCustomAction implements LexerAction {
private readonly _offset;
private readonly _action;
/**
* Constructs a new indexed custom action by associating a character offset
* with a {@link LexerAction}.
*
* Note: This class is only required for lexer actions for which
* {@link LexerAction#isPositionDependent} returns `true`.
*
* @param offset The offset into the input {@link CharStream}, relative to
* the token start index, at which the specified lexer action should be
* executed.
* @param action The lexer action to execute at a particular offset in the
* input {@link CharStream}.
*/
constructor(offset: number, action: LexerAction);
/**
* Gets the location in the input {@link CharStream} at which the lexer
* action should be executed. The value is interpreted as an offset relative
* to the token start index.
*
* @returns The location in the input {@link CharStream} at which the lexer
* action should be executed.
*/
get offset(): number;
/**
* Gets the lexer action to execute.
*
* @returns A {@link LexerAction} object which executes the lexer action.
*/
get action(): LexerAction;
/**
* {@inheritDoc}
*
* @returns This method returns the result of calling {@link #getActionType}
* on the {@link LexerAction} returned by {@link #getAction}.
*/
get actionType(): LexerActionType;
/**
* {@inheritDoc}
* @returns This method returns `true`.
*/
get isPositionDependent(): boolean;
/**
* {@inheritDoc}
*
* This method calls {@link #execute} on the result of {@link #getAction}
* using the provided `lexer`.
*/
execute(lexer: Lexer): void;
hashCode(): number;
equals(obj: any): boolean;
}

Some files were not shown because too many files have changed in this diff Show More