refactored import statements to use object destructuring and avoid repetition

This commit is contained in:
Camilo Roca 2020-03-07 13:59:30 +01:00
parent ae8602a463
commit 51bcf5ffad
5 changed files with 63 additions and 61 deletions

View File

@ -3,9 +3,9 @@
* can be found in the LICENSE.txt file in the project root.
*/
const LL1Analyzer = require('./../LL1Analyzer').LL1Analyzer;
const IntervalSet = require('./../IntervalSet').IntervalSet;
const Token = require('./../Token').Token;
const {LL1Analyzer} = require('./../LL1Analyzer');
const {IntervalSet} = require('./../IntervalSet');
const {Token} = require('./../Token').Token;
class ATN {
constructor(grammarType , maxTokenType) {

View File

@ -3,9 +3,9 @@
* can be found in the LICENSE.txt file in the project root.
*/
const DecisionState = require('./ATNState').DecisionState;
const SemanticContext = require('./SemanticContext').SemanticContext;
const Hash = require("../Utils").Hash;
const {DecisionState} = require('./ATNState');
const {SemanticContext} = require('./SemanticContext');
const {Hash} = require("../Utils");
function checkParams(params, isCfg) {

View File

@ -5,10 +5,8 @@
const ATN = require('./ATN');
const Utils = require('./../Utils');
const Hash = Utils.Hash;
const Set = Utils.Set;
const SemanticContext = require('./SemanticContext').SemanticContext;
const merge = require('./../PredictionContext').merge;
const {SemanticContext} = require('./SemanticContext');
const {merge} = require('./../PredictionContext');
function hashATNConfig(c) {
return c.hashCodeForConfigSet();
@ -42,7 +40,7 @@ class ATNConfigSet {
* All configs but hashed by (s, i, _, pi) not including context. Wiped out
* when we go readonly as this set becomes a DFA state
*/
this.configLookup = new Set(hashATNConfig, equalATNConfigs);
this.configLookup = new Utils.Set(hashATNConfig, equalATNConfigs);
/**
* Indicates that this configuration set is part of a full context
* LL prediction. It will be used to determine how to merge $. With SLL
@ -124,7 +122,7 @@ class ATNConfigSet {
}
getStates() {
const states = new Set();
const states = new Utils.Set();
for (let i = 0; i < this.configs.length; i++) {
states.add(this.configs[i].state);
}
@ -174,7 +172,7 @@ class ATNConfigSet {
}
hashCode() {
const hash = new Hash();
const hash = new Utils.Hash();
hash.update(this.configs);
return hash.finish();
}
@ -214,7 +212,7 @@ class ATNConfigSet {
}
this.configs = [];
this.cachedHashCode = -1;
this.configLookup = new Set();
this.configLookup = new Utils.Set();
}
setReadonly(readOnly) {
@ -245,7 +243,7 @@ class ATNConfigSet {
class OrderedATNConfigSet extends ATNConfigSet {
constructor() {
super();
this.configLookup = new Set();
this.configLookup = new Utils.Set();
}
}

View File

@ -3,50 +3,57 @@
* can be found in the LICENSE.txt file in the project root.
*/
const Token = require('./../Token').Token;
const {Token} = require('./../Token');
const ATN = require('./ATN');
const ATNType = require('./ATNType');
const ATNStates = require('./ATNState');
const ATNState = ATNStates.ATNState;
const BasicState = ATNStates.BasicState;
const DecisionState = ATNStates.DecisionState;
const BlockStartState = ATNStates.BlockStartState;
const BlockEndState = ATNStates.BlockEndState;
const LoopEndState = ATNStates.LoopEndState;
const RuleStartState = ATNStates.RuleStartState;
const RuleStopState = ATNStates.RuleStopState;
const TokensStartState = ATNStates.TokensStartState;
const PlusLoopbackState = ATNStates.PlusLoopbackState;
const StarLoopbackState = ATNStates.StarLoopbackState;
const StarLoopEntryState = ATNStates.StarLoopEntryState;
const PlusBlockStartState = ATNStates.PlusBlockStartState;
const StarBlockStartState = ATNStates.StarBlockStartState;
const BasicBlockStartState = ATNStates.BasicBlockStartState;
const Transitions = require('./Transition');
const Transition = Transitions.Transition;
const AtomTransition = Transitions.AtomTransition;
const SetTransition = Transitions.SetTransition;
const NotSetTransition = Transitions.NotSetTransition;
const RuleTransition = Transitions.RuleTransition;
const RangeTransition = Transitions.RangeTransition;
const ActionTransition = Transitions.ActionTransition;
const EpsilonTransition = Transitions.EpsilonTransition;
const WildcardTransition = Transitions.WildcardTransition;
const PredicateTransition = Transitions.PredicateTransition;
const PrecedencePredicateTransition = Transitions.PrecedencePredicateTransition;
const IntervalSet = require('./../IntervalSet').IntervalSet;
const Interval = require('./../IntervalSet').Interval;
const {
ATNState,
BasicState,
DecisionState,
BlockStartState,
BlockEndState,
LoopEndState,
RuleStartState,
RuleStopState,
TokensStartState,
PlusLoopbackState,
StarLoopbackState,
StarLoopEntryState,
PlusBlockStartState,
StarBlockStartState,
BasicBlockStartState
} = require('./ATNState');
const {
Transition,
AtomTransition,
SetTransition,
NotSetTransition,
RuleTransition,
RangeTransition,
ActionTransition,
EpsilonTransition,
WildcardTransition,
PredicateTransition,
PrecedencePredicateTransition
} = require('./Transition')
const {IntervalSet} = require('./../IntervalSet');
const ATNDeserializationOptions = require('./ATNDeserializationOptions');
const LexerActions = require('./LexerAction');
const LexerActionType = LexerActions.LexerActionType;
const LexerSkipAction = LexerActions.LexerSkipAction;
const LexerChannelAction = LexerActions.LexerChannelAction;
const LexerCustomAction = LexerActions.LexerCustomAction;
const LexerMoreAction = LexerActions.LexerMoreAction;
const LexerTypeAction = LexerActions.LexerTypeAction;
const LexerPushModeAction = LexerActions.LexerPushModeAction;
const LexerPopModeAction = LexerActions.LexerPopModeAction;
const LexerModeAction = LexerActions.LexerModeAction;
const {
LexerActionType,
LexerSkipAction,
LexerChannelAction,
LexerCustomAction,
LexerMoreAction,
LexerTypeAction,
LexerPushModeAction,
LexerPopModeAction,
LexerModeAction,
} = require('./LexerAction');
// This is the earliest supported serialized UUID.
// stick to serialized version for now, we don't need a UUID instance
const BASE_SERIALIZED_UUID = "AADB8D7E-AEEF-4415-AD2B-8204D6CF042E";

View File

@ -12,8 +12,7 @@ const {ATNState, RuleStopState} = require('./ATNState');
const {ATNConfig} = require('./ATNConfig');
const {ATNConfigSet} = require('./ATNConfigSet');
const {Token} = require('./../Token');
const {DFAState} = require('./../dfa/DFAState');
const {PredPrediction} = require('./../dfa/DFAState');
const {DFAState, PredPrediction} = require('./../dfa/DFAState');
const ATNSimulator = require('./ATNSimulator');
const PredictionMode = require('./PredictionMode');
const RuleContext = require('./../RuleContext');
@ -23,8 +22,7 @@ const PredictionContext = require('./../PredictionContext');
const {Interval} = require('./../IntervalSet');
const {Transition, SetTransition, NotSetTransition, RuleTransition, ActionTransition} = require('./Transition');
const {NoViableAltException} = require('./../error/Errors');
const {SingletonPredictionContext} = require('./../PredictionContext');
const {predictionContextFromRuleContext} = require('./../PredictionContext');
const {SingletonPredictionContext, predictionContextFromRuleContext} = require('./../PredictionContext');
/**
@ -1716,5 +1714,4 @@ class ParserATNSimulator extends ATNSimulator {
}
}
module.exports = ParserATNSimulator;