Comparing version 2.0.5 to 2.0.6
@@ -32,4 +32,14 @@ import { DFAState } from "../dfa/DFAState.js"; | ||
constructor(atn: ATN, sharedContextCache: PredictionContextCache | null); | ||
/** | ||
* Clear the DFA cache used by the current instance. Since the DFA cache may | ||
* be shared by multiple ATN simulators, this method may affect the | ||
* performance (but not accuracy) of other parsers which are being used | ||
* concurrently. | ||
* | ||
* @throws UnsupportedOperationException if the current instance does not | ||
* support clearing the DFA. | ||
*/ | ||
clearDFA(): void; | ||
getCachedContext(context: PredictionContext): PredictionContext; | ||
getSharedContextCache(): PredictionContextCache | null; | ||
} |
@@ -58,2 +58,3 @@ import { Lexer } from "../Lexer.js"; | ||
getTokenName(tt: number): string; | ||
clearDFA(): void; | ||
protected matchATN(input: CharStream): number; | ||
@@ -60,0 +61,0 @@ protected execATN(input: CharStream, ds0: DFAState): number; |
@@ -281,2 +281,3 @@ import { NoViableAltException } from "../NoViableAltException.js"; | ||
reset(): void; | ||
clearDFA(): void; | ||
adaptivePredict(input: TokenStream, decision: number, outerContext: ParserRuleContext | null): number; | ||
@@ -283,0 +284,0 @@ /** |
import { Interval } from "./misc/Interval.js"; | ||
import { IntStream } from "./IntStream.js"; | ||
export declare class CharStream implements IntStream { | ||
export interface CharStream extends IntStream { | ||
/** | ||
* 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(): void; | ||
/** | ||
* get a substring from the stream at start to stop (inclusive). | ||
* @param start Start index | ||
* @param stop Stop index | ||
*/ | ||
getText(start: number, stop: number): string; | ||
/** | ||
* get a substring from the stream at specified interval (inclusive). | ||
* @param interval | ||
*/ | ||
getText(interval: Interval): string; | ||
} | ||
export declare class CharStreamImpl implements CharStream { | ||
#private; | ||
@@ -5,0 +24,0 @@ name: string; |
@@ -7,13 +7,20 @@ import { IComparable } from "../utils/helpers.js"; | ||
} | ||
export declare class HashMap<Key extends IComparable, Value> { | ||
private data; | ||
export declare class HashMap<TKey extends IComparable, TValue> { | ||
#private; | ||
/** | ||
* Threshold for using hashing amd searching the bucket instead of a linear search. | ||
* Set to 0 to disable linear search and always use the hash function. | ||
*/ | ||
static LINEAR_SEARCH_THRESHOLD: number; | ||
private hashFunction; | ||
private equalsFunction; | ||
constructor(hashFunction?: HashFunction, equalsFunction?: EqualsFunction); | ||
set(key: Key, value: Value): Value; | ||
containsKey(key: Key): boolean; | ||
get(key: Key): Value | null; | ||
entries(): Array<Entry<Key, Value>>; | ||
getKeys(): Key[]; | ||
getValues(): Value[]; | ||
set(key: TKey, value: TValue): TValue; | ||
private addEntry; | ||
private replaceEntry; | ||
containsKey(key: TKey): boolean; | ||
get(key: TKey): TValue | null; | ||
entries(): Array<Entry<TKey, TValue>>; | ||
getKeys(): TKey[]; | ||
getValues(): TValue[]; | ||
toString(): string; | ||
@@ -20,0 +27,0 @@ get length(): number; |
@@ -5,3 +5,8 @@ import { IComparable } from "../utils/helpers.js"; | ||
export declare class HashSet<T extends IComparable> { | ||
private data; | ||
#private; | ||
/** | ||
* Threshold for using hashing amd searching the bucket instead of a linear search. | ||
* Set to 0 to disable linear search and always use the hash function. | ||
*/ | ||
static LINEAR_SEARCH_THRESHOLD: number; | ||
private hashFunction; | ||
@@ -8,0 +13,0 @@ private equalsFunction; |
{ | ||
"name": "antlr4ng", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"type": "module", | ||
"description": "Alternative JavaScript/TypeScript runtime for ANTLR4", | ||
"main": "dist/antlr4.mjs", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
@@ -43,8 +44,13 @@ "repository": "https://github.com/mike-lischke/antlr4ng", | ||
"tsc": "tsc --watch", | ||
"build": "tsc && npm run generate-test-parser && esbuild ./src/index.js --main-fields=module,main --bundle --outfile=dist/antlr4.mjs --format=esm --sourcemap", | ||
"build-minified": "tsc && npm run generate-test-parser && esbuild ./src/index.js --bundle --outfile=dist/antlr4.mjs --format=esm --sourcemap --minify", | ||
"build": "npm run generate-test-parser && tsc && npm run build-cjs && npm run build-mjs", | ||
"build-minified": "npm run generate-test-parser && tsc && npm run build-cjs-minified && npm run build-mjs-minified", | ||
"build-bundle": "esbuild ./src/index.js --main-fields=module,main --bundle --sourcemap", | ||
"build-mjs": "npm run build-bundle -- --outfile=dist/index.mjs --format=esm", | ||
"build-mjs-minified": "npm run build-mjs -- --minify", | ||
"build-cjs": "npm run build-bundle -- --outfile=dist/index.cjs --format=cjs", | ||
"build-cjs-minified": "npm run build-cjs -- --minify", | ||
"full-test": "npm run test && npm run run-benchmarks", | ||
"test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js --no-coverage", | ||
"generate-test-parser": "cli/index.js -Dlanguage=TypeScript -o tests/benchmarks/generated -visitor -listener -Xexact-output-dir tests/benchmarks/MySQLLexer.g4 tests/benchmarks/MySQLParser.g4", | ||
"generate-xpath-lexer": "cli/index.js -Dlanguage=TypeScript -o src/tree/xpath/generated -no-visitor -no-listener -Xexact-output-dir src/tree/xpath/XPathLexer.g4", | ||
"generate-test-parser": "node cli/index.js -Dlanguage=TypeScript -o tests/benchmarks/generated -visitor -listener -Xexact-output-dir tests/benchmarks/MySQLLexer.g4 tests/benchmarks/MySQLParser.g4", | ||
"generate-xpath-lexer": "node cli/index.js -Dlanguage=TypeScript -o src/tree/xpath/generated -no-visitor -no-listener -Xexact-output-dir src/tree/xpath/XPathLexer.g4", | ||
"run-benchmarks": "node --no-warnings --experimental-vm-modules --loader ts-node/esm tests/benchmarks/run-benchmarks.ts", | ||
@@ -56,4 +62,5 @@ "profile benchmarks": "node --no-warnings --experimental-vm-modules --prof --loader ts-node/esm tests/benchmarks/run-benchmarks.ts", | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/antlr4.mjs" | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.mjs" | ||
} | ||
} |
@@ -126,6 +126,6 @@ [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/mike-lischke/antlr4ng/nodejs.yml?style=for-the-badge&logo=github)](https://github.com/mike-lischke/antlr4ng/actions/workflows/nodejs.yml) | ||
| ---- | -------- | ------- | | ||
| Query Collection| 5930 ms | 338 ms | | ||
| Example File | 1074 ms | 194 ms | | ||
| Large Inserts | 14226 ms | 14248 ms | | ||
| Total | 21290 ms | 14800 ms | | ||
| Query Collection| 4823 ms | 372 ms | | ||
| Example File | 680 ms | 196 ms | | ||
| Large Inserts | 15176 ms | 15115 ms | | ||
| Total | 20738 ms | 15704 ms | | ||
@@ -148,2 +148,8 @@ The numbers are interesting. While the cold run for the query collection is almost 3 seconds faster with pure TS, the overall numbers in warm state are worse. So it's not a pure JS vs. TS situation, but something else must have additional influence and this will be investigated. After all the TypeScript code is ultimately transpiled to JS, so it's probably a matter of how effective the TS code is translated to JS. | ||
### 2.0.6 | ||
- Optimizations in HashMap and HashSet (from Peter van Gulik). This can have dramatic speed improvements, depending on the grammar. In the unit tests this shows mostly by a faster cold start. | ||
- Added CommonJS builds back. Especially when running unit tests using Node.js a CommonJS variant is simpler to handle. | ||
- Added clearDFA() methods in the simulators. | ||
### 2.0.5 | ||
@@ -150,0 +156,0 @@ |
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
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
618682
148
7886
230