Fix various javascript warnings and typos
This commit is contained in:
parent
107f40c63c
commit
954649d5aa
|
@ -73,4 +73,4 @@ const CharStreams = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = CharStreams
|
||||
module.exports = CharStreams;
|
||||
|
|
|
@ -99,11 +99,11 @@ class IntervalSet {
|
|||
const r = this.intervals[k + 1];
|
||||
// if r contained in l
|
||||
if (l.stop >= r.stop) {
|
||||
this.intervals.pop(k + 1);
|
||||
this.intervals = this.intervals.splice(k + 1, 1);
|
||||
this.reduce(k);
|
||||
} else if (l.stop >= r.start) {
|
||||
this.intervals[k] = new Interval(l.start, r.stop);
|
||||
this.intervals.pop(k + 1);
|
||||
this.intervals = this.intervals.splice(k + 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -423,12 +423,12 @@ function titleCase(str) {
|
|||
function equalArrays(a, b) {
|
||||
if (!Array.isArray(a) || !Array.isArray(b))
|
||||
return false;
|
||||
if (a == b)
|
||||
if (a === b)
|
||||
return true;
|
||||
if (a.length != b.length)
|
||||
if (a.length !== b.length)
|
||||
return false;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (a[i] == b[i])
|
||||
if (a[i] === b[i])
|
||||
continue;
|
||||
if (!a[i].equals || !a[i].equals(b[i]))
|
||||
return false;
|
||||
|
|
|
@ -156,7 +156,7 @@ class LexerATNConfig extends ATNConfig {
|
|||
equals(other) {
|
||||
return this === other ||
|
||||
(other instanceof LexerATNConfig &&
|
||||
this.passedThroughNonGreedyDecision == other.passedThroughNonGreedyDecision &&
|
||||
this.passedThroughNonGreedyDecision === other.passedThroughNonGreedyDecision &&
|
||||
(this.lexerActionExecutor ? this.lexerActionExecutor.equals(other.lexerActionExecutor) : !other.lexerActionExecutor) &&
|
||||
super.equals(other));
|
||||
}
|
||||
|
|
|
@ -589,7 +589,7 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
}
|
||||
const fullCtx = true;
|
||||
let foundExactAmbig = false;
|
||||
let reach = null;
|
||||
let reach;
|
||||
let previous = s0;
|
||||
input.seek(startIndex);
|
||||
let t = input.LA(1);
|
||||
|
@ -1253,7 +1253,7 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
// both epsilon transitions and non-epsilon transitions.
|
||||
}
|
||||
for(let i = 0;i<p.transitions.length; i++) {
|
||||
if(i==0 && this.canDropLoopEntryEdgeInLeftRecursiveRule(config))
|
||||
if(i === 0 && this.canDropLoopEntryEdgeInLeftRecursiveRule(config))
|
||||
continue;
|
||||
|
||||
const t = p.transitions[i];
|
||||
|
@ -1308,9 +1308,9 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
// the context has an empty stack case. If so, it would mean
|
||||
// global FOLLOW so we can't perform optimization
|
||||
// Are we the special loop entry/exit state? or SLL wildcard
|
||||
if(p.stateType != ATNState.STAR_LOOP_ENTRY)
|
||||
if(p.stateType !== ATNState.STAR_LOOP_ENTRY)
|
||||
return false;
|
||||
if(p.stateType != ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision ||
|
||||
if(p.stateType !== ATNState.STAR_LOOP_ENTRY || !p.isPrecedenceDecision ||
|
||||
config.context.isEmpty() || config.context.hasEmptyPath())
|
||||
return false;
|
||||
|
||||
|
@ -1318,7 +1318,7 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
const numCtxs = config.context.length;
|
||||
for(let i=0; i<numCtxs; i++) { // for each stack context
|
||||
const returnState = this.atn.states[config.context.getReturnState(i)];
|
||||
if (returnState.ruleIndex != p.ruleIndex)
|
||||
if (returnState.ruleIndex !== p.ruleIndex)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1332,29 +1332,29 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
const returnStateNumber = config.context.getReturnState(i);
|
||||
const returnState = this.atn.states[returnStateNumber];
|
||||
// all states must have single outgoing epsilon edge
|
||||
if (returnState.transitions.length != 1 || !returnState.transitions[0].isEpsilon)
|
||||
if (returnState.transitions.length !== 1 || !returnState.transitions[0].isEpsilon)
|
||||
return false;
|
||||
|
||||
// Look for prefix op case like 'not expr', (' type ')' expr
|
||||
const returnStateTarget = returnState.transitions[0].target;
|
||||
if ( returnState.stateType == ATNState.BLOCK_END && returnStateTarget == p )
|
||||
if ( returnState.stateType === ATNState.BLOCK_END && returnStateTarget === p )
|
||||
continue;
|
||||
|
||||
// Look for 'expr op expr' or case where expr's return state is block end
|
||||
// of (...)* internal block; the block end points to loop back
|
||||
// which points to p but we don't need to check that
|
||||
if ( returnState == blockEndState )
|
||||
if ( returnState === blockEndState )
|
||||
continue;
|
||||
|
||||
// Look for ternary expr ? expr : expr. The return state points at block end,
|
||||
// which points at loop entry state
|
||||
if ( returnStateTarget == blockEndState )
|
||||
if ( returnStateTarget === blockEndState )
|
||||
continue;
|
||||
|
||||
// Look for complex prefix 'between expr and expr' case where 2nd expr's
|
||||
// return state points at block end state of (...)* internal block
|
||||
if (returnStateTarget.stateType == ATNState.BLOCK_END && returnStateTarget.transitions.length == 1
|
||||
&& returnStateTarget.transitions[0].isEpsilon && returnStateTarget.transitions[0].target == p)
|
||||
if (returnStateTarget.stateType === ATNState.BLOCK_END && returnStateTarget.transitions.length === 1
|
||||
&& returnStateTarget.transitions[0].isEpsilon && returnStateTarget.transitions[0].target === p)
|
||||
continue;
|
||||
|
||||
// anything else ain't conforming
|
||||
|
@ -1401,7 +1401,7 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
|
||||
actionTransition(config, t) {
|
||||
if (this.debug) {
|
||||
const index = t.actionIndex==-1 ? 65535 : t.actionIndex;
|
||||
const index = t.actionIndex === -1 ? 65535 : t.actionIndex;
|
||||
console.log("ACTION edge " + t.ruleIndex + ":" + index);
|
||||
}
|
||||
return new ATNConfig({state:t.target}, config);
|
||||
|
@ -1659,7 +1659,7 @@ class ParserATNSimulator extends ATNSimulator {
|
|||
* state was not already present
|
||||
*/
|
||||
addDFAState(dfa, D) {
|
||||
if (D == ATNSimulator.ERROR) {
|
||||
if (D === ATNSimulator.ERROR) {
|
||||
return D;
|
||||
}
|
||||
const existing = dfa.states.get(D);
|
||||
|
|
|
@ -501,7 +501,7 @@ const PredictionMode = {
|
|||
getConflictingAltSubsets: function(configs) {
|
||||
const configToAlts = new Map();
|
||||
configToAlts.hashFunction = function(cfg) { hashStuff(cfg.state.stateNumber, cfg.context); };
|
||||
configToAlts.equalsFunction = function(c1, c2) { return c1.state.stateNumber==c2.state.stateNumber && c1.context.equals(c2.context);}
|
||||
configToAlts.equalsFunction = function(c1, c2) { return c1.state.stateNumber === c2.state.stateNumber && c1.context.equals(c2.context);};
|
||||
configs.items.map(function(cfg) {
|
||||
let alts = configToAlts.get(cfg);
|
||||
if (alts === null) {
|
||||
|
@ -557,6 +557,6 @@ const PredictionMode = {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = PredictionMode;
|
||||
|
|
|
@ -111,7 +111,7 @@ class DFA {
|
|||
*/
|
||||
setPrecedenceDfa(precedenceDfa) {
|
||||
if (this.precedenceDfa!==precedenceDfa) {
|
||||
this._states = new DFAStatesSet();
|
||||
this._states = new Set();
|
||||
if (precedenceDfa) {
|
||||
const precedenceState = new DFAState(null, new ATNConfigSet());
|
||||
precedenceState.edges = [];
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
* and what kind of problem occurred.
|
||||
*/
|
||||
|
||||
const {PredicateTransition} = require('./../atn/Transition')
|
||||
const {PredicateTransition} = require('./../atn/Transition');
|
||||
const {Interval} = require('../IntervalSet').Interval;
|
||||
|
||||
class RecognitionException extends Error {
|
||||
constructor(params) {
|
||||
|
@ -76,9 +77,9 @@ class LexerNoViableAltException extends RecognitionException {
|
|||
}
|
||||
|
||||
toString() {
|
||||
let symbol = ""
|
||||
let symbol = "";
|
||||
if (this.startIndex >= 0 && this.startIndex < this.input.size) {
|
||||
symbol = this.input.getText((this.startIndex,this.startIndex));
|
||||
symbol = this.input.getText(new Interval(this.startIndex,this.startIndex));
|
||||
}
|
||||
return "LexerNoViableAltException" + symbol;
|
||||
}
|
||||
|
|
|
@ -4,22 +4,24 @@ if (!String.prototype.codePointAt) {
|
|||
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
|
||||
var defineProperty = (function() {
|
||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||
let result;
|
||||
try {
|
||||
var object = {};
|
||||
var $defineProperty = Object.defineProperty;
|
||||
var result = $defineProperty(object, object, object) && $defineProperty;
|
||||
} catch(error) {}
|
||||
const object = {};
|
||||
const $defineProperty = Object.defineProperty;
|
||||
result = $defineProperty(object, object, object) && $defineProperty;
|
||||
} catch(error) {
|
||||
}
|
||||
return result;
|
||||
}());
|
||||
var codePointAt = function(position) {
|
||||
const codePointAt = function(position) {
|
||||
if (this == null) {
|
||||
throw TypeError();
|
||||
}
|
||||
var string = String(this);
|
||||
var size = string.length;
|
||||
const string = String(this);
|
||||
const size = string.length;
|
||||
// `ToInteger`
|
||||
var index = position ? Number(position) : 0;
|
||||
if (index != index) { // better `isNaN`
|
||||
let index = position ? Number(position) : 0;
|
||||
if (index !== index) { // better `isNaN`
|
||||
index = 0;
|
||||
}
|
||||
// Account for out-of-bounds indices:
|
||||
|
@ -27,8 +29,8 @@ if (!String.prototype.codePointAt) {
|
|||
return undefined;
|
||||
}
|
||||
// Get the first code unit
|
||||
var first = string.charCodeAt(index);
|
||||
var second;
|
||||
const first = string.charCodeAt(index);
|
||||
let second;
|
||||
if ( // check if it’s the start of a surrogate pair
|
||||
first >= 0xD800 && first <= 0xDBFF && // high surrogate
|
||||
size > index + 1 // there is a next code unit
|
||||
|
|
|
@ -1,35 +1,36 @@
|
|||
/*! https://mths.be/fromcodepoint v0.2.1 by @mathias */
|
||||
if (!String.fromCodePoint) {
|
||||
(function() {
|
||||
var defineProperty = (function() {
|
||||
const defineProperty = (function() {
|
||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||
let result;
|
||||
try {
|
||||
var object = {};
|
||||
var $defineProperty = Object.defineProperty;
|
||||
var result = $defineProperty(object, object, object) && $defineProperty;
|
||||
const object = {};
|
||||
const $defineProperty = Object.defineProperty;
|
||||
result = $defineProperty(object, object, object) && $defineProperty;
|
||||
} catch(error) {}
|
||||
return result;
|
||||
}());
|
||||
var stringFromCharCode = String.fromCharCode;
|
||||
var floor = Math.floor;
|
||||
var fromCodePoint = function(_) {
|
||||
var MAX_SIZE = 0x4000;
|
||||
var codeUnits = [];
|
||||
var highSurrogate;
|
||||
var lowSurrogate;
|
||||
var index = -1;
|
||||
var length = arguments.length;
|
||||
const stringFromCharCode = String.fromCharCode;
|
||||
const floor = Math.floor;
|
||||
const fromCodePoint = function(_) {
|
||||
const MAX_SIZE = 0x4000;
|
||||
const codeUnits = [];
|
||||
let highSurrogate;
|
||||
let lowSurrogate;
|
||||
let index = -1;
|
||||
const length = arguments.length;
|
||||
if (!length) {
|
||||
return '';
|
||||
}
|
||||
var result = '';
|
||||
let result = '';
|
||||
while (++index < length) {
|
||||
var codePoint = Number(arguments[index]);
|
||||
let codePoint = Number(arguments[index]);
|
||||
if (
|
||||
!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
|
||||
codePoint < 0 || // not a valid Unicode code point
|
||||
codePoint > 0x10FFFF || // not a valid Unicode code point
|
||||
floor(codePoint) != codePoint // not an integer
|
||||
floor(codePoint) !== codePoint // not an integer
|
||||
) {
|
||||
throw RangeError('Invalid code point: ' + codePoint);
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ if (!String.fromCodePoint) {
|
|||
lowSurrogate = (codePoint % 0x400) + 0xDC00;
|
||||
codeUnits.push(highSurrogate, lowSurrogate);
|
||||
}
|
||||
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
|
||||
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
||||
result += stringFromCharCode.apply(null, codeUnits);
|
||||
codeUnits.length = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue