Comparing version 4.11.0 to 4.12.0-beta.0
{ | ||
"name": "antlr4", | ||
"version": "4.11.0", | ||
"version": "4.12.0-beta.0", | ||
"type": "module", | ||
"description": "JavaScript runtime for ANTLR4", | ||
"main": "src/antlr4/index.js", | ||
"main": "dist/antlr4.js", | ||
"types": "src/antlr4/index.d.ts", | ||
"repository": "antlr/antlr4.git", | ||
@@ -21,6 +22,10 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.16.11", | ||
"babel-loader": "^8.2.4", | ||
"eslint-plugin-es5": "^1.5.0", | ||
"eslint-webpack-plugin": "^3.1.1", | ||
"@babel/core": "^7.19.1", | ||
"@babel/preset-env": "^7.19.4", | ||
"@types/node": "^18.7.23", | ||
"@babel/eslint-parser": "^7.19.1", | ||
"babel-loader": "^8.2.5", | ||
"compression-webpack-plugin": "^10.0.0", | ||
"eslint": "^8.23.1", | ||
"eslint-webpack-plugin": "^3.2.0", | ||
"glob-parent": "^6.0.2", | ||
@@ -30,4 +35,7 @@ "jasmine": "^4.0.2", | ||
"minimist": "^1.2.6", | ||
"source-map-support": "^0.5.21", | ||
"terser-webpack-plugin": "^5.3.6", | ||
"typescript": "^4.8.3", | ||
"webpack": "^5.66.0", | ||
"webpack-cli": "^4.9.1" | ||
"webpack-cli": "^4.10.0" | ||
}, | ||
@@ -39,3 +47,3 @@ "scripts": { | ||
"engines": { | ||
"node": ">=14" | ||
"node": ">=16" | ||
}, | ||
@@ -42,0 +50,0 @@ "browser": { |
@@ -61,4 +61,4 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
export default class ATNDeserializer { | ||
constructor(options) { | ||
if ( options=== undefined || options === null ) { | ||
@@ -65,0 +65,0 @@ options = ATNDeserializationOptions.defaultOptions; |
@@ -11,3 +11,4 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
import PredictionMode from './PredictionMode.js'; | ||
import PredictionContextCache from './PredictionContextCache.js'; | ||
export default { ATN, ATNDeserializer, LexerATNSimulator, ParserATNSimulator, PredictionMode } | ||
export default { ATN, ATNDeserializer, LexerATNSimulator, ParserATNSimulator, PredictionMode, PredictionContextCache } |
@@ -342,7 +342,7 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
// Get the text of all tokens in this buffer./// | ||
// Get the text of all tokens in this buffer./// | ||
getText(interval) { | ||
this.lazyInit(); | ||
this.fill(); | ||
if (interval === undefined || interval === null) { | ||
if (!interval) { | ||
interval = new Interval(0, this.tokens.length - 1); | ||
@@ -375,9 +375,14 @@ } | ||
// Get all tokens from lexer until EOF/// | ||
// Get all tokens from lexer until EOF/// | ||
fill() { | ||
this.lazyInit(); | ||
while (this.fetch(1000) === 1000) { | ||
continue; | ||
} | ||
// noinspection StatementWithEmptyBodyJS | ||
while (this.fetch(1000) === 1000); | ||
} | ||
} | ||
Object.defineProperty(BufferedTokenStream, "size", { | ||
get: function() { | ||
return this.tokens.length; | ||
} | ||
}) |
@@ -42,2 +42,12 @@ import Token from "./Token.js"; | ||
cloneWithType(type) { | ||
const t = new CommonToken(this.source, type, this.channel, this.start, this.stop); | ||
t.tokenIndex = this.tokenIndex; | ||
t.line = this.line; | ||
t.column = this.column; | ||
if (type === Token.EOF) | ||
t.text = ""; | ||
return t; | ||
} | ||
toString() { | ||
@@ -44,0 +54,0 @@ let txt = this.text; |
@@ -37,7 +37,5 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
export default class ParserRuleContext extends RuleContext { | ||
constructor(parent, invokingStateNumber) { | ||
parent = parent || null; | ||
invokingStateNumber = invokingStateNumber || null; | ||
super(parent, invokingStateNumber); | ||
this.ruleIndex = -1; | ||
/** | ||
@@ -44,0 +42,0 @@ * If we are debugging or building a parse tree for a visitor, |
@@ -66,3 +66,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
getRuleContext() { | ||
get ruleContext() { | ||
return this; | ||
@@ -69,0 +69,0 @@ } |
@@ -15,5 +15,7 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
export default class FailedPredicateException extends RecognitionException { | ||
constructor(recognizer, predicate, message) { | ||
super({ | ||
message: formatMessage(predicate, message || null), recognizer: recognizer, | ||
message: formatMessage(predicate, message || null), | ||
recognizer: recognizer, | ||
input: recognizer.getInputStream(), ctx: recognizer._ctx | ||
@@ -20,0 +22,0 @@ }); |
@@ -15,2 +15,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
export default class RecognitionException extends Error { | ||
constructor(params) { | ||
@@ -17,0 +18,0 @@ super(params.message); |
@@ -5,13 +5,15 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
*/ | ||
import './utils/stringHashCode.js'; | ||
import './polyfills/codepointat.js'; | ||
import './polyfills/fromcodepoint.js'; | ||
import { default as atn } from './atn/index.js'; | ||
import { default as dfa } from './dfa/index.js'; | ||
import { default as context } from './context/index.js'; | ||
import { default as misc } from './misc/index.js'; | ||
import { default as tree } from './tree/index.js'; | ||
import { default as error } from './error/index.js'; | ||
import { default as CharStreams } from './CharStreams.js'; | ||
import { default as Utils } from './utils/index.js'; | ||
import Token from './Token.js'; | ||
import CommonToken from './CommonToken.js'; | ||
import { default as CharStreams } from './CharStreams.js'; | ||
import InputStream from './InputStream.js'; | ||
import CharStream from './InputStream.js'; | ||
import FileStream from './FileStream.js'; | ||
@@ -21,14 +23,44 @@ import CommonTokenStream from './CommonTokenStream.js'; | ||
import Parser from './Parser.js'; | ||
import RuleContext from './context/RuleContext.js'; | ||
import ParserRuleContext from './context/ParserRuleContext.js'; | ||
import ATN from './atn/ATN.js'; | ||
import PredictionMode from './atn/PredictionMode.js'; | ||
import LL1Analyzer from './atn/LL1Analyzer.js'; | ||
import ATNDeserializer from './atn/ATNDeserializer.js'; | ||
import LexerATNSimulator from './atn/LexerATNSimulator.js'; | ||
import ParserATNSimulator from './atn/ParserATNSimulator.js'; | ||
import PredictionContextCache from './atn/PredictionContextCache.js'; | ||
import ParserRuleContext from './context/ParserRuleContext.js'; | ||
import DFA from "./dfa/DFA.js"; | ||
import RecognitionException from "./error/RecognitionException.js"; | ||
import FailedPredicateException from "./error/FailedPredicateException.js"; | ||
import NoViableAltException from "./error/NoViableAltException.js"; | ||
import BailErrorStrategy from "./error/BailErrorStrategy.js"; | ||
import Interval from './misc/Interval.js'; | ||
import IntervalSet from './misc/IntervalSet.js'; | ||
import LL1Analyzer from './atn/LL1Analyzer.js'; | ||
import { default as Utils } from './utils/index.js'; | ||
import ParseTreeListener from "./tree/ParseTreeListener.js"; | ||
import ParseTreeWalker from "./tree/ParseTreeWalker.js"; | ||
import ErrorListener from "./error/ErrorListener.js" | ||
import DiagnosticErrorListener from "./error/DiagnosticErrorListener.js" | ||
import RuleNode from "./tree/RuleNode.js" | ||
import TerminalNode from "./tree/TerminalNode.js" | ||
import arrayToString from "./utils/arrayToString.js" | ||
const antlr4 = { | ||
atn, dfa, tree, error, Token, CommonToken, CharStreams, InputStream, FileStream, CommonTokenStream, Lexer, Parser, | ||
PredictionContextCache, ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils | ||
}; | ||
export default { | ||
atn, dfa, context, misc, tree, error, Token, CommonToken, CharStreams, CharStream, InputStream, FileStream, CommonTokenStream, Lexer, Parser, | ||
ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils | ||
} | ||
export default antlr4; | ||
export { | ||
Token, CommonToken, CharStreams, CharStream, InputStream, FileStream, CommonTokenStream, Lexer, Parser, | ||
RuleNode, TerminalNode, ParseTreeWalker, RuleContext, ParserRuleContext, Interval, IntervalSet, | ||
PredictionMode, LL1Analyzer, ParseTreeListener, ATN, ATNDeserializer, PredictionContextCache, LexerATNSimulator, ParserATNSimulator, DFA, | ||
RecognitionException, NoViableAltException, FailedPredicateException, ErrorListener, DiagnosticErrorListener, BailErrorStrategy, | ||
arrayToString | ||
} | ||
/* eslint no-unused-vars: [ "off"] */ | ||
// need to import unused to force loading | ||
import StringHashCode from './utils/stringHashCode.js'; | ||
import CodePointAt from './polyfills/codepointat.js'; | ||
import FromCodePoint from './polyfills/fromcodepoint.js'; |
@@ -6,124 +6,11 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
import Token from './Token.js'; | ||
import './polyfills/codepointat.js'; | ||
import './polyfills/fromcodepoint.js'; | ||
import CharStream from './CharStream.js'; | ||
/** | ||
* If decodeToUnicodeCodePoints is true, the input is treated | ||
* as a series of Unicode code points. | ||
* | ||
* Otherwise, the input is treated as a series of 16-bit UTF-16 code | ||
* units. | ||
*/ | ||
export default class InputStream { | ||
* @deprecated Use CharStream instead | ||
*/ | ||
export default class InputStream extends CharStream { | ||
constructor(data, decodeToUnicodeCodePoints) { | ||
this.name = "<empty>"; | ||
this.strdata = data; | ||
this.decodeToUnicodeCodePoints = decodeToUnicodeCodePoints || false; | ||
// _loadString - Vacuum all input from a string and then treat it like a buffer. | ||
this._index = 0; | ||
this.data = []; | ||
if (this.decodeToUnicodeCodePoints) { | ||
for (let i = 0; i < this.strdata.length; ) { | ||
const codePoint = this.strdata.codePointAt(i); | ||
this.data.push(codePoint); | ||
i += codePoint <= 0xFFFF ? 1 : 2; | ||
} | ||
} else { | ||
this.data = new Array(this.strdata.length); | ||
for (let i = 0; i < this.strdata.length; i++) { | ||
const codeUnit = this.strdata.charCodeAt(i); | ||
this.data[i] = codeUnit; | ||
} | ||
} | ||
this._size = this.data.length; | ||
super(data, decodeToUnicodeCodePoints); | ||
} | ||
/** | ||
* Reset the stream so that it's in the same state it was | ||
* when the object was created *except* the data array is not | ||
* touched. | ||
*/ | ||
reset() { | ||
this._index = 0; | ||
} | ||
consume() { | ||
if (this._index >= this._size) { | ||
// assert this.LA(1) == Token.EOF | ||
throw ("cannot consume EOF"); | ||
} | ||
this._index += 1; | ||
} | ||
LA(offset) { | ||
if (offset === 0) { | ||
return 0; // undefined | ||
} | ||
if (offset < 0) { | ||
offset += 1; // e.g., translate LA(-1) to use offset=0 | ||
} | ||
const pos = this._index + offset - 1; | ||
if (pos < 0 || pos >= this._size) { // invalid | ||
return Token.EOF; | ||
} | ||
return this.data[pos]; | ||
} | ||
LT(offset) { | ||
return this.LA(offset); | ||
} | ||
// mark/release do nothing; we have entire buffer | ||
mark() { | ||
return -1; | ||
} | ||
release(marker) { | ||
} | ||
/** | ||
* consume() ahead until p==_index; can't just set p=_index as we must | ||
* update line and column. If we seek backwards, just set p | ||
*/ | ||
seek(_index) { | ||
if (_index <= this._index) { | ||
this._index = _index; // just jump; don't update stream state (line, | ||
// ...) | ||
return; | ||
} | ||
// seek forward | ||
this._index = Math.min(_index, this._size); | ||
} | ||
getText(start, stop) { | ||
if (stop >= this._size) { | ||
stop = this._size - 1; | ||
} | ||
if (start >= this._size) { | ||
return ""; | ||
} else { | ||
if (this.decodeToUnicodeCodePoints) { | ||
let result = ""; | ||
for (let i = start; i <= stop; i++) { | ||
result += String.fromCodePoint(this.data[i]); | ||
} | ||
return result; | ||
} else { | ||
return this.strdata.slice(start, stop + 1); | ||
} | ||
} | ||
} | ||
toString() { | ||
return this.strdata; | ||
} | ||
get index(){ | ||
return this._index; | ||
} | ||
get size(){ | ||
return this._size; | ||
} | ||
} |
@@ -62,1 +62,4 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
} | ||
const CodePointAt = String.prototype.codePointAt; | ||
export default CodePointAt; |
@@ -70,1 +70,4 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
} | ||
const FromCodePoint = String.prototype.fromCodePoint; | ||
export default FromCodePoint; |
@@ -18,3 +18,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
checkVersion(toolVersion) { | ||
const runtimeVersion = "4.11.0"; | ||
const runtimeVersion = "4.11.1"; | ||
if (runtimeVersion!==toolVersion) { | ||
@@ -146,2 +146,6 @@ console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion); | ||
get atn() { | ||
return this._interp.atn; | ||
} | ||
get state(){ | ||
@@ -148,0 +152,0 @@ return this._stateNumber; |
@@ -12,2 +12,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
export default class Token { | ||
constructor() { | ||
@@ -14,0 +15,0 @@ this.source = null; |
@@ -42,3 +42,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
enterRule(listener, r) { | ||
const ctx = r.getRuleContext(); | ||
const ctx = r.ruleContext; | ||
listener.enterEveryRule(ctx); | ||
@@ -55,3 +55,3 @@ ctx.enterRule(listener); | ||
exitRule(listener, r) { | ||
const ctx = r.getRuleContext(); | ||
const ctx = r.ruleContext; | ||
ctx.exitRule(listener); | ||
@@ -58,0 +58,0 @@ listener.exitEveryRule(ctx); |
@@ -9,5 +9,5 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
getRuleContext(){ | ||
get ruleContext() { | ||
throw new Error("missing interface implementation") | ||
} | ||
} |
@@ -52,3 +52,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
if (t instanceof RuleNode) { | ||
const context = t.getRuleContext() | ||
const context = t.ruleContext; | ||
const altNumber = context.getAltNumber(); | ||
@@ -55,0 +55,0 @@ // use const value of ATN.INVALID_ALT_NUMBER to avoid circular dependency |
@@ -5,4 +5,5 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
*/ | ||
import arrayToString from "../utils/arrayToString.js"; | ||
import arrayToString from "./arrayToString.js"; | ||
import stringToCharArray from "./stringToCharArray.js"; | ||
export default { arrayToString }; | ||
export default { arrayToString, stringToCharArray }; |
@@ -6,5 +6,7 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
String.prototype.seed = String.prototype.seed || Math.round(Math.random() * Math.pow(2, 32)); | ||
export const StringSeedHashCode = Math.round(Math.random() * Math.pow(2, 32)); | ||
String.prototype.hashCode = function () { | ||
String.prototype.seed = StringSeedHashCode; | ||
export default function StringHashCode () { | ||
const key = this.toString(); | ||
@@ -64,2 +66,4 @@ let h1b, k1; | ||
return h1 >>> 0; | ||
}; | ||
} | ||
String.prototype.hashCode = StringHashCode; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1364960
214
13001
17
1
80
1
4