New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

antlr4

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antlr4 - npm Package Compare versions

Comparing version 4.5.2 to 4.5.3

2

atn/ATN.js

@@ -81,3 +81,3 @@ // [The "BSD license"]

s.nextTokenWithinRule = this.nextTokensInContext(s, null);
s.nextTokenWithinRule.readonly = true;
s.nextTokenWithinRule.readOnly = true;
return s.nextTokenWithinRule;

@@ -84,0 +84,0 @@ };

@@ -53,3 +53,3 @@ //

props.state = params.state || null;
props.alt = params.alt || null;
props.alt = (params.alt === undefined) ? null : params.alt;
props.context = params.context || null;

@@ -166,3 +166,5 @@ props.semanticContext = params.semanticContext || null;

return false;
} else if (this.lexerActionExecutor !== other.lexerActionExecutor) {
} else if (this.lexerActionExecutor ?
!this.lexerActionExecutor.equals(other.lexerActionExecutor)
: !other.lexerActionExecutor) {
return false;

@@ -169,0 +171,0 @@ } else {

@@ -81,3 +81,3 @@ //

// we've made this readonly.
this.readonly = false;
this.readOnly = false;
// Track the elements as they are added to the set; supports get(i)///

@@ -116,3 +116,3 @@ this.configs = [];

}
if (this.readonly) {
if (this.readOnly) {
throw "This set is readonly";

@@ -173,3 +173,3 @@ }

ATNConfigSet.prototype.optimizeConfigs = function(interpreter) {
if (this.readonly) {
if (this.readOnly) {
throw "This set is readonly";

@@ -208,3 +208,3 @@ }

ATNConfigSet.prototype.hashString = function() {
if (this.readonly) {
if (this.readOnly) {
if (this.cachedHashString === "-1") {

@@ -252,3 +252,3 @@ this.cachedHashString = this.hashConfigs();

ATNConfigSet.prototype.clear = function() {
if (this.readonly) {
if (this.readOnly) {
throw "This set is readonly";

@@ -261,5 +261,5 @@ }

ATNConfigSet.prototype.setReadonly = function(readonly) {
this.readonly = readonly;
if (readonly) {
ATNConfigSet.prototype.setReadonly = function(readOnly) {
this.readOnly = readOnly;
if (readOnly) {
this.configLookup = null; // can't mod, no need for lookup cache

@@ -266,0 +266,0 @@ }

@@ -45,3 +45,3 @@ //

// of the performance-critical {@link LexerATNConfig//hashCode} operation.
this.hashString = lexerActions.toString(); // "".join([str(la) for la in
this._hashString = lexerActions.toString(); // "".join([str(la) for la in
// lexerActions]))

@@ -162,3 +162,3 @@ return this;

LexerActionExecutor.prototype.hashString = function() {
return this.hashString;
return this._hashString;
};

@@ -171,5 +171,14 @@

return false;
} else if (this._hashString != other._hashString) {
return false;
} else if (this.lexerActions.length != other.lexerActions.length) {
return false;
} else {
return this.hashString === other.hashString &&
this.lexerActions === other.lexerActions;
var numActions = this.lexerActions.length
for (var idx = 0; idx < numActions; ++idx) {
if (!this.lexerActions[idx].equals(other.lexerActions[idx])) {
return false;
}
}
return true;
}

@@ -176,0 +185,0 @@ };

@@ -41,2 +41,5 @@ //

var RuleStopState = require('./ATNState').RuleStopState;
var ATNConfigSet = require('./ATNConfigSet').ATNConfigSet;
var ATNConfig = require('./ATNConfig').ATNConfig;
var SemanticContext = require('./SemanticContext').SemanticContext;

@@ -584,2 +587,2 @@ function PredictionMode() {

exports.PredictionMode = PredictionMode;
exports.PredictionMode = PredictionMode;

@@ -304,3 +304,3 @@ //

operands.map(function(o) {
result = result === null ? o : SemanticPredicate.andContext(result, o);
result = result === null ? o : SemanticContext.andContext(result, o);
});

@@ -412,3 +412,3 @@ return result;

AND.prototype.toString = function() {
OR.prototype.toString = function() {
var s = "";

@@ -415,0 +415,0 @@ this.opnds.map(function(o) {

@@ -263,2 +263,3 @@ //

// Given a starting index, return the index of the next token on channel.

@@ -304,3 +305,3 @@ // Return i if tokens[i] is on channel. Return -1 if there are no tokens

this.lazyInit();
if (this.tokenIndex < 0 || tokenIndex >= this.tokens.length) {
if (tokenIndex < 0 || tokenIndex >= this.tokens.length) {
throw "" + tokenIndex + " not in 0.." + this.tokens.length - 1;

@@ -307,0 +308,0 @@ }

@@ -33,2 +33,4 @@ //

var ATNConfigSet = require('./../atn/ATNConfigSet').ATNConfigSet;
var Utils = require('./../Utils');
var Set = Utils.Set;

@@ -167,2 +169,2 @@ // Map a predicate to a predicted alternative.///

exports.DFAState = DFAState;
exports.PredPrediction = PredPrediction;
exports.PredPrediction = PredPrediction;

@@ -272,3 +272,4 @@ //

this.reportUnwantedToken(recognizer);
var expecting = recognizer.getExpectedTokens();
var expecting = new IntervalSet();
expecting.addSet(recognizer.getExpectedTokens());
var whatFollowsLoopIterationOrRule = expecting.addSet(this.getErrorRecoverySet(recognizer));

@@ -275,0 +276,0 @@ this.consumeUntil(recognizer, whatFollowsLoopIterationOrRule);

@@ -37,8 +37,5 @@ //

var InputStream = require('./InputStream').InputStream;
try {
var fs = require("fs");
} catch(ex) {
// probably running from browser, no "Node.js/fs" makes sense
}
var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined';
var fs = isNodeJs ? require("fs") : null;
function FileStream(fileName) {

@@ -45,0 +42,0 @@ var data = fs.readFileSync(fileName, "utf8");

@@ -6,3 +6,3 @@ exports.atn = require('./atn/index');

exports.Token = require('./Token').Token;
exports.CommonToken = require('./Token').Token;
exports.CommonToken = require('./Token').CommonToken;
exports.InputStream = require('./InputStream').InputStream;

@@ -9,0 +9,0 @@ exports.FileStream = require('./FileStream').FileStream;

@@ -148,3 +148,3 @@ //

LL1Analyzer.prototype._LOOK = function(s, stopState , ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF) {
var c = new ATNConfig({state:s, alt:0}, ctx);
var c = new ATNConfig({state:s, alt:0, context: ctx}, null);
if (lookBusy.contains(c)) {

@@ -151,0 +151,0 @@ return;

{
"name": "antlr4",
"version": "4.5.2",
"version": "4.5.3",
"description": "JavaScript runtime for ANTLR4",
"main": "src/antlr4/index.js",
"repository": "antlr/antlr4-javascript.git",
"repository": "antlr/antlr4.git",
"keywords": [

@@ -16,5 +16,5 @@ "lexer",

"bugs": {
"url": "https://github.com/antlr/antlr4-javascript/issues"
"url": "https://github.com/antlr/antlr4/issues"
},
"homepage": "https://github.com/antlr/antlr4-javascript"
"homepage": "https://github.com/antlr/antlr4"
}

@@ -325,3 +325,3 @@ // [The "BSD license"]

if (this.getTokenStream() !== null) {
var tokenSource = this.getTokenStream().getTokenSource();
var tokenSource = this.getTokenStream().tokenSource;
if (tokenSource instanceof Lexer) {

@@ -412,2 +412,3 @@ lexer = tokenSource;

}
node.invokingState = this.state;
if (hasListener) {

@@ -455,2 +456,3 @@ this._parseListeners.map(function(listener) {

Parser.prototype.enterOuterAlt = function(localctx, altNum) {
localctx.setAltNumber(altNum);
// if we have new localctx, make sure we replace existing ctx

@@ -457,0 +459,0 @@ // that is previous child of parse tree

@@ -217,3 +217,3 @@ // [The "BSD license"]

} else {
return Interval(this.start.tokenIndex, this.stop.tokenIndex);
return new Interval(this.start.tokenIndex, this.stop.tokenIndex);
}

@@ -220,0 +220,0 @@ };

@@ -115,3 +115,3 @@ //

}
var existing = this.cache[ctx];
var existing = this.cache[ctx] || null;
if (existing !== null) {

@@ -118,0 +118,0 @@ return existing;

@@ -11,4 +11,4 @@ # JavaScript target for ANTLR 4

See https://theantlrguy.atlassian.net/wiki/display/ANTLR4/JavaScript+Target for more information on using ANTLR in JavaScript
See https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md for more information on using ANTLR in JavaScript

@@ -48,3 +48,3 @@ //

Recognizer.prototype.checkVersion = function(toolVersion) {
var runtimeVersion = "4.5";
var runtimeVersion = "4.5.3";
if (runtimeVersion!==toolVersion) {

@@ -51,0 +51,0 @@ console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion);

@@ -54,2 +54,3 @@ // [The "BSD license"]

var INVALID_INTERVAL = require('./tree/Tree').INVALID_INTERVAL;
var INVALID_ALT_NUMBER = require('./atn/ATN').INVALID_ALT_NUMBER;

@@ -117,2 +118,17 @@ function RuleContext(parent, invokingState) {

// For rule associated with this parse tree internal node, return
// the outer alternative number used to match the input. Default
// implementation does not compute nor store this alt num. Create
// a subclass of ParserRuleContext with backing field and set
// option contextSuperClass.
// to set it.
RuleContext.prototype.getAltNumber = function() { return INVALID_ALT_NUMBER; }
// Set the outer alternative number for this context node. Default
// implementation does nothing to avoid backing field overhead for
// trees that don't need it. Create
// a subclass of ParserRuleContext with backing field and set
// option contextSuperClass.
RuleContext.prototype.setAltNumber = function(altNumber) { }
RuleContext.prototype.getChild = function(i) {

@@ -119,0 +135,0 @@ return null;

var Tree = require('./Tree');
exports.Trees = require('./Tree').Trees;
exports.Trees = require('./Trees').Trees;
exports.RuleNode = Tree.RuleNode;
exports.ParseTreeListener = Tree.ParseTreeListener;
exports.ParseTreeVisitor = Tree.ParseTreeVisitor;
exports.ParseTreeWalker = Tree.ParseTreeWalker;
exports.ParseTreeWalker = Tree.ParseTreeWalker;

@@ -38,3 +38,5 @@ // [The "BSD license"]

var INVALID_INTERVAL = new Interval(-1, -2);
var Utils = require('../Utils.js');
function Tree() {

@@ -88,2 +90,29 @@ return this;

ParseTreeVisitor.prototype.visit = function(ctx) {
if (Utils.isArray(ctx)) {
var self = this;
return ctx.map(function(child) { return visitAtom(self, child)});
} else {
return visitAtom(this, ctx);
}
};
ParseTreeVisitor.prototype.visitTerminal = function(node) {
};
ParseTreeVisitor.prototype.visitErrorNode = function(node) {
};
var visitAtom = function(visitor, ctx) {
if (ctx.parser === undefined) { //is terminal
return;
}
var name = ctx.parser.ruleNames[ctx.ruleIndex];
var funcName = "visit" + Utils.titleCase(name);
return visitor[funcName](ctx);
};
function ParseTreeListener() {

@@ -90,0 +119,0 @@ return this;

@@ -37,2 +37,4 @@ /*

var ParserRuleContext = require('./../ParserRuleContext').ParserRuleContext;
var RuleContext = require('./../RuleContext').RuleContext;
var INVALID_ALT_NUMBER = require('./../atn/ATN').INVALID_ALT_NUMBER;

@@ -79,4 +81,8 @@

if(ruleNames!==null) {
if (t instanceof RuleNode) {
return ruleNames[t.getRuleContext().ruleIndex];
if (t instanceof RuleContext) {
var altNumber = t.getAltNumber();
if ( altNumber!=INVALID_ALT_NUMBER ) {
return ruleNames[t.ruleIndex]+":"+altNumber;
}
return ruleNames[t.ruleIndex];
} else if ( t instanceof ErrorNode) {

@@ -120,3 +126,3 @@ return t.toString();

};
Trees.findAllTokenNodes = function(t, ttype) {

@@ -123,0 +129,0 @@ return Trees.findAllNodes(t, ttype, true);

@@ -194,3 +194,10 @@ function arrayToString(a) {

exports.isArray = function (entity) {
return Object.prototype.toString.call( entity ) === '[object Array]'
};
exports.titleCase = function(str) {
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1);});
};
exports.Set = Set;

@@ -197,0 +204,0 @@ exports.BitSet = BitSet;

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc