Comparing version 4.12.0 to 4.13.0
{ | ||
"name": "antlr4", | ||
"version": "4.12.0", | ||
"version": "4.13.0", | ||
"type": "module", | ||
"description": "JavaScript runtime for ANTLR4", | ||
"browser": "dist/antlr4.web.js", | ||
"main": "dist/antlr4.node.js", | ||
"main": "dist/antlr4.node.mjs", | ||
"types": "src/antlr4/index.d.ts", | ||
@@ -28,2 +28,3 @@ "repository": "antlr/antlr4.git", | ||
"babel-loader": "^8.2.5", | ||
"c8": "^7.12.0", | ||
"compression-webpack-plugin": "^10.0.0", | ||
@@ -44,7 +45,25 @@ "eslint": "^8.23.1", | ||
"build": "webpack", | ||
"test": "jasmine" | ||
"test": "jasmine", | ||
"coverage": "c8 jasmine", | ||
"lint": "eslint src/antlr4/" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"exports": { | ||
".": { | ||
"node": { | ||
"types": "src/index.node.d.ts", | ||
"import": "./dist/antlr4.node.mjs", | ||
"require": "./dist/antlr4.node.cjs", | ||
"default": "./dist/antlr4.node.mjs" | ||
}, | ||
"browser": { | ||
"types": "src/index.web.d.ts", | ||
"import": "./dist/antlr4.web.mjs", | ||
"require": "./dist/antlr4.web.cjs", | ||
"default": "./dist/antlr4.web.mjs" | ||
} | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import antlr4 from "../src/antlr4/index.js"; | ||
import antlr4 from "../src/antlr4/index.node.js"; | ||
const IntervalSet = antlr4.IntervalSet; | ||
@@ -3,0 +3,0 @@ |
{ | ||
"spec_dir": "spec", | ||
"spec_files": [ | ||
"**/*Spec.[c|m]*js", | ||
"**/*Spec.js" | ||
@@ -5,0 +6,0 @@ ], |
@@ -86,2 +86,6 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
get size() { | ||
return this.tokens.length; | ||
} | ||
get(index) { | ||
@@ -152,3 +156,3 @@ this.lazyInit(); | ||
// Get all tokens from start..stop inclusively/// | ||
// Get all tokens from start..stop inclusively/// | ||
getTokens(start, stop, types) { | ||
@@ -235,3 +239,3 @@ if (types === undefined) { | ||
// Reset this token stream by setting its token source./// | ||
// Reset this token stream by setting its token source./// | ||
setTokenSource(tokenSource) { | ||
@@ -284,3 +288,3 @@ this.tokenSource = tokenSource; | ||
getHiddenTokensToRight(tokenIndex, | ||
channel) { | ||
channel) { | ||
if (channel === undefined) { | ||
@@ -306,3 +310,3 @@ channel = -1; | ||
getHiddenTokensToLeft(tokenIndex, | ||
channel) { | ||
channel) { | ||
if (channel === undefined) { | ||
@@ -309,0 +313,0 @@ channel = -1; |
@@ -7,4 +7,2 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
import Token from './Token.js'; | ||
import './polyfills/codepointat.js'; | ||
import './polyfills/fromcodepoint.js'; | ||
@@ -11,0 +9,0 @@ /** |
@@ -21,4 +21,4 @@ import {RuleContext} from "./RuleContext"; | ||
getTokens(ttype: number): TerminalNode[]; | ||
getTypedRuleContext<T extends ParserRuleContext>(ctxType: { new (parser?: Parser, parent?: ParserRuleContext, invokingState?: number, ...args: any[]) : T}, i: number): T; | ||
getTypedRuleContexts<T extends ParserRuleContext>(ctxType: { new (parser?: Parser, parent?: ParserRuleContext, invokingState?: number, ...args: any[]) : T}): T[]; | ||
getTypedRuleContext<T extends ParserRuleContext, P extends Parser>(ctxType: { new (parser?: P, parent?: ParserRuleContext, invokingState?: number, ...args: any[]) : T}, i: number): T; | ||
getTypedRuleContexts<T extends ParserRuleContext, P extends Parser>(ctxType: { new (parser?: P, parent?: ParserRuleContext, invokingState?: number, ...args: any[]) : T}): T[]; | ||
} |
@@ -19,2 +19,7 @@ import {ErrorStrategy} from "./ErrorStrategy"; | ||
inErrorRecoveryMode(recognizer: Parser): void; | ||
beginErrorCondition(recognizer: Parser): void; | ||
getMissingSymbol(recognizer: Parser): Token; | ||
} |
export * from './RecognitionException'; | ||
export * from './NoViableAltException'; | ||
export * from './FailedPredicateException'; | ||
export * from './InputMismatchException'; | ||
export * from './ErrorStrategy'; | ||
export * from './BailErrorStrategy'; | ||
export * from './DefaultErrorStrategy'; | ||
export * from './ErrorListener'; | ||
export * from './DiagnosticErrorListener'; | ||
import {ATNConfigSet} from "../atn"; | ||
import {Recognizer} from "../Recognizer"; | ||
import { Token } from "../Token"; | ||
import {RecognitionException} from "./RecognitionException"; | ||
@@ -11,2 +12,3 @@ | ||
startToken: Token; | ||
} |
@@ -5,2 +5,3 @@ import {ParserRuleContext, RuleContext} from "../context"; | ||
import {CharStream} from "../CharStream"; | ||
import {Token} from "../Token"; | ||
@@ -17,4 +18,4 @@ export interface ExceptionParams { | ||
ctx: RuleContext; | ||
offendingToken: Token | null; | ||
constructor(params: ExceptionParams); | ||
} |
@@ -21,1 +21,2 @@ export * from "./InputStream"; | ||
export * from './utils'; | ||
export * from './TokenStreamRewriter'; |
@@ -47,6 +47,7 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
import arrayToString from "./utils/arrayToString.js" | ||
import TokenStreamRewriter from './TokenStreamRewriter.js'; | ||
export default { | ||
atn, dfa, context, misc, tree, error, Token, CommonToken, CharStreams, CharStream, InputStream, FileStream, CommonTokenStream, Lexer, Parser, | ||
ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils | ||
ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils, TokenStreamRewriter | ||
} | ||
@@ -61,7 +62,1 @@ | ||
} | ||
/* 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'; |
@@ -46,6 +46,7 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
import arrayToString from "./utils/arrayToString.js" | ||
import TokenStreamRewriter from './TokenStreamRewriter.js'; | ||
export default { | ||
atn, dfa, context, misc, tree, error, Token, CommonToken, CharStreams, CharStream, InputStream, CommonTokenStream, Lexer, Parser, | ||
ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils | ||
ParserRuleContext, Interval, IntervalSet, LL1Analyzer, Utils, TokenStreamRewriter | ||
} | ||
@@ -60,7 +61,1 @@ | ||
} | ||
/* 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'; |
@@ -31,2 +31,3 @@ import {Recognizer} from "./Recognizer"; | ||
emitEOF(): Token; | ||
getAllTokens(): Token[]; | ||
} |
@@ -5,2 +5,4 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
*/ | ||
import { stringHashCode } from "../utils/stringHashCode.js"; | ||
export default class HashCode { | ||
@@ -31,3 +33,3 @@ | ||
case 'string': | ||
k = value.hashCode(); | ||
k = stringHashCode(value); | ||
break; | ||
@@ -34,0 +36,0 @@ default: |
import {TokenStream} from "./TokenStream"; | ||
import {Recognizer} from "./Recognizer"; | ||
import {ErrorStrategy} from "./error"; | ||
import {ErrorStrategy, RecognitionException} from "./error"; | ||
import {IntervalSet} from "./misc"; | ||
@@ -22,2 +22,3 @@ import {ParserATNSimulator} from "./atn"; | ||
printer?: Printer; | ||
syntaxErrorsCount: number; | ||
@@ -40,2 +41,7 @@ constructor(input: TokenStream); | ||
getTokenStream(): TokenStream; | ||
reset(): void; | ||
setTokenStream(input: TokenStream): void; | ||
notifyErrorListeners(msg: string, offendingToken: Token, err: RecognitionException | undefined): void; | ||
getCurrentToken(): Token; | ||
} |
@@ -292,2 +292,11 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
/** | ||
* Gets the number of syntax errors reported during parsing. This value is | ||
* incremented each time {@link //notifyErrorListeners} is called. | ||
*/ | ||
get syntaxErrorsCount() { | ||
return this._syntaxErrors; | ||
} | ||
/** | ||
* Match needs to return the current input symbol, which gets put | ||
@@ -294,0 +303,0 @@ * into the label for the associated token ref; e.g., x=ID. |
@@ -18,3 +18,3 @@ /* Copyright (c) 2012-2022 The ANTLR Project. All rights reserved. | ||
checkVersion(toolVersion) { | ||
const runtimeVersion = "4.12.0"; | ||
const runtimeVersion = "4.13.0"; | ||
if (runtimeVersion!==toolVersion) { | ||
@@ -21,0 +21,0 @@ console.log("ANTLR runtime and generated code versions disagree: "+runtimeVersion+"!="+toolVersion); |
@@ -10,2 +10,3 @@ import {CharStream} from "./CharStream"; | ||
column: number; | ||
channel: number; | ||
text: string; | ||
@@ -12,0 +13,0 @@ type: number; |
@@ -12,5 +12,6 @@ import {Interval} from "./misc"; | ||
getText(interval?: Interval): string; | ||
getHiddenTokensToLeft(tokenIndex: number, channelName?: string): Token[]; | ||
getHiddenTokensToRight(tokenIndex: number, channelName?: string): Token[]; | ||
// channelIndex can be retrieved using: lexer.channelNames().findIndex(channelName) | ||
getHiddenTokensToLeft(tokenIndex: number, channelIndex?: number): Token[]; | ||
getHiddenTokensToRight(tokenIndex: number, channelIndex?: number): Token[]; | ||
get(idx: number): Token; | ||
} |
@@ -5,4 +5,6 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
*/ | ||
import { stringHashCode } from "./stringHashCode.js"; | ||
export default function standardHashCodeFunction(a) { | ||
return a ? a.hashCode() : -1; | ||
return a ? typeof a === 'string' ? stringHashCode(a) : a.hashCode() : -1; | ||
} |
@@ -8,6 +8,11 @@ /* Copyright (c) 2012-2022 The ANTLR Project Contributors. All rights reserved. | ||
String.prototype.seed = StringSeedHashCode; | ||
export default function StringHashCode () { | ||
const key = this.toString(); | ||
export function stringHashCode (value) { | ||
if (!value) { | ||
return 0; | ||
} | ||
const type = typeof value; | ||
const key = type === 'string' ? value : type === 'object' && value.toString ? value.toString() : false; | ||
if (!key) { | ||
return 0; | ||
} | ||
let h1b, k1; | ||
@@ -17,3 +22,3 @@ | ||
const bytes = key.length - remainder; | ||
let h1 = String.prototype.seed; | ||
let h1 = StringSeedHashCode; | ||
const c1 = 0xcc9e2d51; | ||
@@ -68,3 +73,1 @@ const c2 = 0x1b873593; | ||
} | ||
String.prototype.hashCode = StringHashCode; |
@@ -8,66 +8,61 @@ import path from 'path'; | ||
const nodeConfig = { | ||
const buildConfig = ( platform, extensions ) => ({ | ||
mode: "production", | ||
entry: './src/antlr4/index.node.js', | ||
entry: `./src/antlr4/index.${platform}.js`, | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'antlr4.node.js', | ||
chunkFormat: "module", | ||
filename: `antlr4.${platform}.${extensions}`, | ||
chunkFormat: extensions === "mjs" ? "module" : "commonjs", | ||
library: { | ||
type: "module" | ||
type: extensions === "mjs" ? "module" : "commonjs" | ||
} | ||
}, | ||
resolve: { | ||
extensions: [ '.js'] | ||
}, | ||
target: "node", | ||
...(platform === 'web' && { | ||
module: { | ||
rules: [{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ 'babel-loader' ] | ||
}] | ||
}, | ||
plugins: [ new ESLintPlugin() ], | ||
experiments: { | ||
outputModule: true | ||
}, | ||
devtool: "source-map" | ||
}; | ||
rules: [{ | ||
test: /\.js$/, | ||
exclude: [ /node_modules/, path.resolve(__dirname, "src/FileStream.js") ], | ||
use: [ 'babel-loader' ] | ||
}] | ||
}, | ||
performance: { | ||
maxAssetSize: 512000, | ||
maxEntrypointSize: 512000 | ||
}, | ||
resolve: { | ||
extensions: [ '.js'], | ||
fallback: { | ||
fs: false | ||
} | ||
}, | ||
}), | ||
const webConfig = { | ||
mode: "production", | ||
entry: './src/antlr4/index.web.js', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'antlr4.web.js', | ||
library: { | ||
type: "module" | ||
} | ||
}, | ||
resolve: { | ||
extensions: [ '.js'], | ||
fallback: { | ||
fs: false | ||
} | ||
}, | ||
target: "web", | ||
module: { | ||
rules: [{ | ||
test: /\.js$/, | ||
exclude: [ /node_modules/, path.resolve(__dirname, "src/FileStream.js") ], | ||
use: [ 'babel-loader' ] | ||
}] | ||
}, | ||
performance: { | ||
maxAssetSize: 512000, | ||
maxEntrypointSize: 512000 | ||
}, | ||
...(platform === 'node' && { | ||
module: { | ||
rules: [{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ 'babel-loader' ] | ||
}] | ||
}, | ||
resolve: { | ||
extensions: [ '.js'], | ||
}, | ||
}), | ||
target: platform, | ||
plugins: [ new ESLintPlugin() ], | ||
devtool: "source-map", | ||
experiments: { | ||
outputModule: true | ||
outputModule: extensions === "mjs" | ||
}, | ||
devtool: "source-map" | ||
}; | ||
}) | ||
export default [ nodeConfig, webConfig ]; | ||
export default [ | ||
buildConfig("node", "cjs"), | ||
buildConfig("node", "mjs"), | ||
buildConfig("web", "cjs"), | ||
buildConfig("web", "mjs"), | ||
]; |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
6298169
233
20096
18
1
5