Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

antlr4ng

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antlr4ng - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

2

dist/atn/ATNConfig.d.ts

@@ -29,3 +29,3 @@ import { SemanticContext } from "./SemanticContext.js";

static duplicate(old: ATNConfig, semanticContext?: SemanticContext): ATNConfig;
static createWithContext(state: ATNState, alt: number, context: PredictionContext, semanticContext?: SemanticContext): ATNConfig;
static createWithContext(state: ATNState, alt: number, context: PredictionContext | null, semanticContext?: SemanticContext): ATNConfig;
static createWithConfig(state: ATNState, config: ATNConfig, context?: PredictionContext): ATNConfig;

@@ -32,0 +32,0 @@ static createWithSemanticContext(state: ATNState, c: ATNConfig, semanticContext?: SemanticContext | null): ATNConfig;

@@ -9,2 +9,3 @@ import { Lexer } from "../Lexer.js";

#private;
static debug: boolean;
readonly decisionToDFA: DFA[];

@@ -11,0 +12,0 @@ readonly recognizer: Lexer | null;

@@ -232,2 +232,8 @@ import { NoViableAltException } from "../NoViableAltException.js";

export declare class ParserATNSimulator extends ATNSimulator {
static traceATNSimulator: boolean;
static debug?: boolean;
static debugAdd: boolean;
static debugClosure: boolean;
static dfaDebug: boolean;
static retryDebug: boolean;
/** SLL, LL, or LL + exact ambig detection? */

@@ -540,9 +546,9 @@ predictionMode: number;

*
* @param dfa The dfa
* @param D The DFA state to add
* @returns The state stored in the DFA. This will be either the existing
* state if `D` is already in the DFA, or `D` itself if the
* state was not already present
* @param dfa The dfa.
* @param newState The DFA state to add.
*
* @returns The state stored in the DFA. This will be either the existing state if `newState` is already in
* the DFA, or `newState` itself if the state was not already present.
*/
protected addDFAState(dfa: DFA, D: DFAState): DFAState;
protected addDFAState(dfa: DFA, newState: DFAState): DFAState;
protected reportAttemptingFullContext(dfa: DFA, conflictingAlts: BitSet, configs: ATNConfigSet, startIndex: number, stopIndex: number): void;

@@ -549,0 +555,0 @@ protected reportContextSensitivity(dfa: DFA, prediction: number, configs: ATNConfigSet, startIndex: number, stopIndex: number): void;

@@ -12,3 +12,3 @@ import { Recognizer } from "../Recognizer.js";

static EMPTY: PredictionContext;
static trace_atn_sim: boolean;
static traceATNSimulator: boolean;
constructor(cachedHashCode: number);

@@ -15,0 +15,0 @@ protected static calculateEmptyHashCode(): number;

@@ -87,3 +87,3 @@ import { Interval } from "./misc/Interval.js";

getSourceInterval(): Interval;
get parent(): this | null;
get parent(): ParserRuleContext | null;
set parent(parent: ParserRuleContext | null);

@@ -90,0 +90,0 @@ depth(): number;

{
"name": "antlr4ng",
"version": "3.0.3",
"version": "3.0.4",
"type": "module",

@@ -27,17 +27,17 @@ "description": "Alternative JavaScript/TypeScript runtime for ANTLR4",

"devDependencies": {
"@mike-lischke/antlr-tgen": "1.0.7",
"@types/jest": "29.5.11",
"@types/node": "20.10.4",
"@mike-lischke/antlr-tgen": "1.0.8",
"@types/jest": "29.5.12",
"@types/node": "20.11.28",
"@types/unicode-properties": "1.3.2",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"esbuild": "0.19.9",
"eslint": "8.56.0",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"esbuild": "0.20.2",
"eslint": "8.57.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "46.9.1",
"eslint-plugin-jsdoc": "48.2.1",
"eslint-plugin-prefer-arrow": "1.2.3",
"jest": "29.7.0",
"ts-jest": "29.1.1",
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"typescript": "5.4.2",
"unicode-properties": "1.4.1"

@@ -44,0 +44,0 @@ },

@@ -84,11 +84,11 @@ [![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)

class MyVisitor extends ExpressionVisitor<number> {
visitAdd(ctx: AddContext): number {
public visitAdd = (ctx: AddContext): number {
return this.visit(ctx.expression(0)) + this.visit(ctx.expression(1));
}
visitMultiply(ctx: MultiplyContext): number {
public visitMultiply = (ctx: MultiplyContext): number {
return this.visit(ctx.expression(0)) * this.visit(ctx.expression(1));
}
visitNumber(ctx: NumberContext): number {
public visitNumber = (ctx: NumberContext): number {
return Number.parseInt(ctx.NUMBER().text);

@@ -102,2 +102,18 @@ }

## Installing Development Dependencies
While antlr4ng has no runtime dependencies (no 3rd party libs are used at runtime), there are a number dev dependencies that are used to run the benchmarks or create custom builds. So, before you do anything else in the repo after cloning it, install the depedencies by running
```bash
npm i
```
in the root folder of the repo. Once this has completed successfully you should be able to use any of the NPM scripts in the project. For example, to generate a release build without source maps run:
```bash
npm run build
```
which will create the `dist/` folder and store the bundled sources for CommonJS and ESM there.
## Tests and Benchmarks

@@ -146,11 +162,11 @@

|---:|---:|---:|---:|---:|---:|
|Query Collection (cold)|1340 ms| <ins>184/2160 (2344) ms</ins>| 7984 ms| 3402 ms| 3331 ms|
| Bitrix Queries (cold)| 195 ms| <ins>69/272 (341) ms</ins>| 1134 ms| 444 ms| 998 ms|
| Large Inserts (cold)|4981 ms|<ins>6323/2279 (8602) ms</ins>|10695 ms|11483 ms|34243 ms|
|Query Collection (warm)| 133 ms| 129/100 (229) ms| <ins>223 ms</ins>| 259 ms| 1177 ms|
|Query Collection (cold)|1340 ms| <ins>187/2232 (2420) ms</ins>| 7984 ms| 3402 ms| 3331 ms|
| Bitrix Queries (cold)| 195 ms| <ins>68/283 (351) ms</ins>| 1134 ms| 444 ms| 998 ms|
| Large Inserts (cold)|4981 ms|<ins>6295/2277 (8572) ms</ins>|10695 ms|11483 ms|34243 ms|
|Total (cold) |6546 ms|<ins>6551/4792 (11343) ms</ins>|19878 ms|15403 ms|38641 ms|
|||||||
|Query Collection (warm)| 133 ms| 130/102 (232) ms| <ins>223 ms</ins>| 259 ms| 1177 ms|
| Bitrix Queries (warm)| 70 ms| 63/73 (136) ms| <ins>110 ms</ins>| 131 ms| 815 ms|
| Large Inserts (warm)|4971 ms|<ins>6368/2284 (8652) ms</ins>|10593 ms|11287 ms|36317 ms|
|||||||
|Total (cold) |6546 ms|<ins>6576/4711 (11287) ms</ins>|19878 ms|15403 ms|38641 ms|
|Total (warm) |5198 ms|<ins>6561/2460 (9021) ms</ins>|10944 ms|11697 ms|38329 ms|
| Large Inserts (warm)|4971 ms|<ins>6281/2281 (8562) ms</ins>|10593 ms|11287 ms|36317 ms|
|Total (warm) |5198 ms|<ins>6474/2456 (8931) ms</ins>|10944 ms|11697 ms|38329 ms|

@@ -192,15 +208,15 @@ Underlined entries are the smallest (not counting C++, which beats them all). For antlr4ng, the times are split into lexing and parsing. Note the high lexer execution times, caused by the large number of predicates (126) + lexer actions (40) in the MySQL lexer.

```bash
loadNewUTF8 average time 354µs size 29191b over 3500 loads of 29191 symbols from Parser.java
loadNewUTF8 average time 74µs size 7552b over 3500 loads of 7552 symbols from RuleContext.java
loadNewUTF8 average time 120µs size 31784b over 3500 loads of 13379 symbols from udhr_hin.txt
loadNewUTF8 average time 353µs size 29191b over 3500 loads of 29191 symbols from Parser.java
loadNewUTF8 average time 75µs size 7552b over 3500 loads of 7552 symbols from RuleContext.java
loadNewUTF8 average time 121µs size 31784b over 3500 loads of 13379 symbols from udhr_hin.txt
lexNewJavaUTF8 average time 669µs over 2000 runs of 29191 symbols
lexNewJavaUTF8 average time 1923µs over 2000 runs of 29191 symbols DFA cleared
lexNewJavaUTF8 average time 706µs over 2000 runs of 29191 symbols
lexNewJavaUTF8 average time 1961µs over 2000 runs of 29191 symbols DFA cleared
lexNewGraphemeUTF8 average time 8098µs over 400 runs of 6614 symbols from udhr_kor.txt
lexNewGraphemeUTF8 average time 8223µs over 400 runs of 6614 symbols from udhr_kor.txt DFA cleared
lexNewGraphemeUTF8 average time 12800µs over 400 runs of 13379 symbols from udhr_hin.txt
lexNewGraphemeUTF8 average time 12856µs over 400 runs of 13379 symbols from udhr_hin.txt DFA cleared
lexNewGraphemeUTF8 average time 205µs over 400 runs of 85 symbols from emoji.txt
lexNewGraphemeUTF8 average time 235µs over 400 runs of 85 symbols from emoji.txt DFA cleared
lexNewGraphemeUTF8 average time 7836µs over 400 runs of 6614 symbols from udhr_kor.txt
lexNewGraphemeUTF8 average time 7946µs over 400 runs of 6614 symbols from udhr_kor.txt DFA cleared
lexNewGraphemeUTF8 average time 12945µs over 400 runs of 13379 symbols from udhr_hin.txt
lexNewGraphemeUTF8 average time 13079µs over 400 runs of 13379 symbols from udhr_hin.txt DFA cleared
lexNewGraphemeUTF8 average time 203µs over 400 runs of 85 symbols from emoji.txt
lexNewGraphemeUTF8 average time 233µs over 400 runs of 85 symbols from emoji.txt DFA cleared
```

@@ -212,2 +228,9 @@

### 3.0.4
- Fixed visitor example in this readme file and added build instructions.
- Added back all debug output in the simulators and the prediction context. Useful for finding low level problems.
- Fixed bug #47 Antlr4ng fails to parse codeql/examples/alias.qll
- Fixed bug #46 ParserRulecontext.parent() incorrectly typed
### 3.0.2 - 3.0.3

@@ -214,0 +237,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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