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 1.0.7 to 1.1.0

dist/antlr4.mjs

24

package.json
{
"name": "antlr4ng",
"version": "1.0.7",
"version": "1.1.0",
"type": "module",
"description": "Alternative JavaScript/TypeScript runtime for ANTLR4",
"browser": "dist/antlr4.web.mjs",
"main": "dist/antlr4.node.mjs",
"main": "dist/antlr4.mjs",
"types": "src/antlr4/index.d.ts",

@@ -57,3 +56,4 @@ "repository": "https://github.com/mike-lischke/antlr4ng",

"generate-test-parser": "cli/index.js -Dlanguage=TypeScript -o spec/benchmarks/generated -visitor -listener -Xexact-output-dir spec/benchmarks/MySQLLexer.g4 spec/benchmarks/MySQLParser.g4",
"benchmarks": "npm run build && npm run generate-test-parser && node --no-warnings=ExperimentalWarning --loader ts-node/esm spec/benchmarks/run-benchmarks.ts"
"run-benchmarks": "node --no-warnings=ExperimentalWarning --loader ts-node/esm spec/benchmarks/run-benchmarks.ts",
"build-benchmarks": "npm run build && npm run generate-test-parser"
},

@@ -64,16 +64,4 @@ "engines": {

"exports": {
".": {
"node": {
"types": "./src/antlr4/index.d.ts",
"import": "./dist/antlr4.node.mjs",
"require": "./dist/antlr4.node.cjs",
"default": "./dist/antlr4.node.mjs"
},
"browser": {
"types": "./src/antlr4/index.d.ts",
"import": "./dist/antlr4.web.mjs",
"require": "./dist/antlr4.web.cjs",
"default": "./dist/antlr4.web.mjs"
}
}
"types": "./src/antlr4/index.d.ts",
"default": "./dist/antlr4.mjs"
},

@@ -80,0 +68,0 @@ "babel": {

@@ -1,10 +0,9 @@

# JavaScript + TypeScript Target Runtime for ANTLR 4
[![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)
[![Weekly Downloads](https://img.shields.io/npm/dw/antlr4ng?style=for-the-badge&color=blue)](https://www.npmjs.com/package/antlr4ng)
[![npm version](https://img.shields.io/npm/v/antlr4ng?style=for-the-badge&color=yellow)](https://www.npmjs.com/package/antlr4ng)
[![Build & Test](https://github.com/mike-lischke/antlr4ng/actions/workflows/nodejs.yml/badge.svg?branch=master)](https://github.com/mike-lischke/antlr4ng/actions/workflows/nodejs.yml)
[![Downloads](https://img.shields.io/npm/dw/antlr4ng?color=blue)](https://www.npmjs.com/package/antlr4ng)
[![npm version](https://img.shields.io/npm/v/antlr4ng?color=yellow)](https://www.npmjs.com/package/antlr4ng)
# TypeScript Target Runtime for ANTLR 4
This package is a fork of the official ANTLR4 JavaScript runtime (with its TypeScript additions), with the following changes:
This package is a fork of the official ANTLR4 JavaScript runtime, with the following changes:
- Much improved TypeScript type definitions.

@@ -17,2 +16,3 @@ - XPath implementation.

- Smaller node package (no test specs or other unnecessary files).
- Bug fixes.

@@ -34,3 +34,3 @@ It is (mostly) a drop-in replacement of the `antlr4` package, and can be used as such. For more information about ANTLR see www.antlr.org. Read more details about the [JavaScript](https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md) and [TypeScript](https://github.com/antlr/antlr4/blob/master/doc/typescript-target.md) targets at the provided links, but keep in mind that this documentation applies to the original JS/TS target.

```
See it's readme for more information.
See [its readme](./cli/ReadMe.md) for more information.

@@ -52,2 +52,14 @@ ## Benchmarks

### 1.1.0
This release includes a lot of cleanup.
- Generated parser rules that can appear as either returning a single parse context or a list of that no longer use the `__list()` appendix in their name. Instead method overloading is used now to distinguish between the two cases.
- The members `getTypedRuleContext` and `getTypedRuleContexts` have been renamed to `getRuleContext` and `getRuleContexts` respectively, just as in the Java runtime.
- There are more renames (`_errHandler` -> 'errorHandler`, `_input` -> `inputStream` and more).
- The package has been stripped down to just a single bundle file. This is an ESM module now, so it can be used in both, node and browser environments. No differentiation is made anymore between the two.
- The internal folder structure has been changed to match the Java runtime.
- Extended some classes, added new type definitions and exported some more classes.
- Improved `BitSet` to use less memory.
### 1.0.6 - 1.0.7

@@ -54,0 +66,0 @@

@@ -7,7 +7,7 @@ /*

import { ATNState } from "../state/ATNState.js";
import { Transition } from "../transition/Transition.js";
import { ATNState } from "./ATNState.js";
import { Transition } from "./Transition.js";
export declare class AbstractPredicateTransition extends Transition {
export declare abstract class AbstractPredicateTransition extends Transition {
public constructor(target: ATNState);
}

@@ -8,8 +8,8 @@ /*

import { IntervalSet } from "../misc/IntervalSet.js";
import { RuleContext } from "../context/RuleContext.js";
import { ATNState } from "../state/ATNState.js";
import { DecisionState } from "../state/DecisionState.js";
import { RuleStartState } from "../state/RuleStartState.js";
import { RuleStopState } from "../state/RuleStopState.js";
import { LexerAction } from "../action/LexerAction.js";
import { RuleContext } from "./RuleContext.js";
import { ATNState } from "./ATNState.js";
import { DecisionState } from "./DecisionState.js";
import { RuleStartState } from "./RuleStartState.js";
import { RuleStopState } from "./RuleStopState.js";
import { LexerAction } from "./LexerAction.js";

@@ -26,6 +26,6 @@ export declare class ATN {

public readonly ruleToStartState: RuleStartState[];
public readonly ruleToStopState: RuleStopState[] | null;
public readonly ruleToStopState: RuleStopState[];
public readonly modeNameToStartState: { [name: string]: RuleStartState; };
public readonly ruleToTokenType: number[] | null;
public readonly lexerActions: LexerAction[] | null;
public readonly ruleToTokenType: number[];
public readonly lexerActions: LexerAction[];
public readonly modeToStartState: RuleStartState[];

@@ -32,0 +32,0 @@

@@ -7,3 +7,3 @@ /*

import { ATNState } from "../state/ATNState.js";
import { ATNState } from "./ATNState.js";

@@ -10,0 +10,0 @@ export declare class ATNConfig {

@@ -7,2 +7,12 @@ /*

export * from "./LexerAction.js";
// export * from "./LexerChannelAction.js";
// export * from "./LexerIndexedCustomAction.js";
// export * from "./LexerModeAction.js";
// export * from "./LexerMoreAction.js";
// export * from "./LexerPopModeAction.js";
// export * from "./LexerPushModeAction.js";
// export * from "./LexerSkipAction.js";
// export * from "./LexerTypeAction.js";
export * from "./ATN.js";

@@ -13,5 +23,44 @@ export * from "./ATNConfig.js";

export * from "./ATNSimulator.js";
export * from "./ATNState.js";
export * from "./ATNStateType.js";
export * from "./BasicState.js";
export * from "./BlockStartState.js";
export * from "./BlockEndState.js";
export * from "./DecisionState.js";
export * from "./LoopEndState.js";
export * from "./PlusBlockStartState.js";
export * from "./PlusLoopbackState.js";
export * from "./RuleStartState.js";
export * from "./RuleStopState.js";
export * from "./StarBlockStartState.js";
export * from "./StarLoopbackState.js";
export * from "./StarLoopEntryState.js";
export * from "./TokensStartState.js";
export * from "./LexerATNSimulator.js";
export * from "./ParserATNSimulator.js";
export * from "./PredictionContextCache.js";
export * from "./PredictionMode.js";
export * from "./PredictionContextCache.js";
//export * from "./ArrayPredictionContext.js";
//export * from "./EmptyPredictionContext.js";
export * from "../ParserRuleContext.js";
//export * from "./PredictionContext.js";
export * from "./RuleContext.js";
//export * from "./SingletonPredictionContext.js";
export * from "./DecisionState.js";
export * from "./RuleStartState.js";
export * from "./RuleStopState.js";
export * from "./ActionTransition.js";
export * from "./AtomTransition.js";
export * from "./EpsilonTransition.js";
export * from "./NotSetTransition.js";
export * from "./PrecedencePredicateTransition.js";
export * from "./PredicateTransition.js";
export * from "./RangeTransition.js";
export * from "./RuleTransition.js";
export * from "./SetTransition.js";
export * from "./Transition.js";
export * from "./TransitionType.js";
export * from "./WildcardTransition.js";

@@ -9,3 +9,3 @@ /*

import { TokenStream } from "../TokenStream.js";
import { ParserRuleContext } from "../context/ParserRuleContext.js";
import { ParserRuleContext } from "../ParserRuleContext.js";
import { DFA } from "../dfa/DFA.js";

@@ -12,0 +12,0 @@ import { ATN } from "./ATN.js";

@@ -8,3 +8,3 @@ /*

import { Parser } from "../Parser.js";
import { RuleContext } from "../context/RuleContext.js";
import { RuleContext } from "./RuleContext.js";
import { SemanticContext } from "./SemanticContext.js";

@@ -11,0 +11,0 @@

@@ -8,3 +8,3 @@ /*

import { Parser } from "../Parser.js";
import { RuleContext } from "../context/RuleContext.js";
import { RuleContext } from "./RuleContext.js";
import { SemanticContext } from "./SemanticContext.js";

@@ -11,0 +11,0 @@

@@ -8,3 +8,3 @@ /*

import { Parser } from "../Parser.js";
import { RuleContext } from "../context/RuleContext.js";
import { RuleContext } from "./RuleContext.js";

@@ -11,0 +11,0 @@ export declare class SemanticContext {

@@ -8,4 +8,6 @@ /*

import { InputStream } from "./InputStream.js";
import { Recognizer } from "./Recognizer.js";
import { Token } from "./Token.js";
import { TokenSource } from "./TokenSource.js";
import { ATNSimulator } from "./atn/ATNSimulator.js";

@@ -23,3 +25,4 @@ export declare class CommonToken extends Token {

public cloneWithType(type: number): CommonToken;
public toString(): string;
public toString(recognizer?: Recognizer<ATNSimulator>): string;
}

@@ -23,11 +23,22 @@ /*

export * from "./IntStream.js";
export * from "./LexerInterpreter.js";
export * from "./ParserInterpreter.js";
export * from "./InterpreterRuleContext.js";
export * from "./RecognitionException.js";
export * from "./NoViableAltException.js";
export * from "./FailedPredicateException.js";
export * from "./InputMismatchException.js";
export * from "./ANTLRErrorStrategy.js";
export * from "./BailErrorStrategy.js";
export * from "./DefaultErrorStrategy.js";
export * from "./BaseErrorListener.js";
export * from "./DiagnosticErrorListener.js";
export * from "./ParseCancellationException.js";
export * from "./LexerNoViableAltException.js";
export * from "./atn/index.js";
export * from "./dfa/index.js";
export * from "./context/index.js";
export * from "./misc/index.js";
export * from "./tree/index.js";
export * from "./state/index.js";
export * from "./error/index.js";
export * from "./utils/index.js";
export * from "./transition/index.js";

@@ -27,3 +27,2 @@ /*

public _input: CharStream;
public _factory: TokenFactory<Token>;

@@ -45,3 +44,4 @@ public _tokenFactorySourcePair: [TokenSource | null, InputStream | null];

public inputStream: CharStream | undefined;
public get inputStream(): CharStream;
public set inputStream(value: CharStream);

@@ -48,0 +48,0 @@ protected _modeStack: number[];

@@ -10,2 +10,8 @@ /*

export declare class IntervalSet {
// eslint-disable-next-line @typescript-eslint/naming-convention
public static readonly COMPLETE_CHAR_SET: IntervalSet;
// eslint-disable-next-line @typescript-eslint/naming-convention
public static readonly EMPTY_SET: IntervalSet;
public isNil: boolean;

@@ -28,3 +34,7 @@ public minElement: number;

public reduce(pos: number): void;
public complement(start: number, stop: number): IntervalSet;
public complement(minElement: number, maxElement: number): IntervalSet;
public complement(vocabulary: IntervalSet): IntervalSet;
public and(other: IntervalSet): IntervalSet;
public contains(i: number): boolean;

@@ -39,2 +49,5 @@ public removeRange(l: number, h: number): void;

public toArray(): number[];
public isReadOnly(): boolean;
public setReadonly(readonly: boolean): void;
}

@@ -12,17 +12,14 @@ /*

import { ParserATNSimulator } from "./atn/ParserATNSimulator.js";
import { ParserRuleContext } from "./context/ParserRuleContext.js";
import { ErrorStrategy } from "./error/ErrorStrategy.js";
import { RecognitionException } from "./error/RecognitionException.js";
import { ParserRuleContext } from "./ParserRuleContext.js";
import { ANTLRErrorStrategy } from "./ANTLRErrorStrategy.js";
import { RecognitionException } from "./RecognitionException.js";
import { IntervalSet } from "./misc/IntervalSet.js";
import { ParseTreeListener } from "./tree/ParseTreeListener.js";
import { Printer } from "./utils/Printer.js";
export declare abstract class Parser extends Recognizer<ParserATNSimulator> {
public _input: TokenStream;
public _ctx: ParserRuleContext;
public _errHandler: ErrorStrategy;
public errorHandler: ANTLRErrorStrategy;
public matchedEOF: boolean;
public buildParseTrees: boolean;
public printer?: Printer;
protected _ctx: ParserRuleContext;
protected _parseListeners: ParseTreeListener[] | null;

@@ -32,2 +29,4 @@

public get context(): ParserRuleContext;
public reset(): void;

@@ -45,7 +44,11 @@ public match(ttype: number): Token;

public getATNWithBypassAlts(): string;
public getInputStream(): TokenStream;
public setInputStream(input: TokenStream): void;
public getTokenStream(): TokenStream;
public setTokenStream(input: TokenStream): void;
public get tokenStream(): TokenStream;
public set tokenStream(input: TokenStream);
public override get inputStream(): TokenStream;
public override set inputStream(input: TokenStream);
public get syntaxErrorCount(): number;
public getCurrentToken(): Token;

@@ -61,3 +64,3 @@ public notifyErrorListeners(msg: string, offendingToken: Token | null, err: RecognitionException | null): void;

public pushNewRecursionContext(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
public unrollRecursionContexts(parentCtx: ParserRuleContext): void;
public unrollRecursionContexts(parent: ParserRuleContext): void;
public getInvokingContext(ruleIndex: number): ParserRuleContext;

@@ -64,0 +67,0 @@ public precpred(localctx: ParserRuleContext, precedence: number): boolean;

@@ -7,2 +7,3 @@ /*

import { IntStream } from "./IntStream.js";
import { Token } from "./Token.js";

@@ -12,5 +13,5 @@ import { Vocabulary } from "./Vocabulary.js";

import { ATNSimulator } from "./atn/ATNSimulator.js";
import { RuleContext } from "./context/RuleContext.js";
import { BaseErrorListener } from "./error/BaseErrorListener.js";
import { RecognitionException } from "./error/RecognitionException.js";
import { RuleContext } from "./atn/RuleContext.js";
import { BaseErrorListener } from "./BaseErrorListener.js";
import { RecognitionException } from "./RecognitionException.js";

@@ -21,3 +22,3 @@ export declare abstract class Recognizer<ATNInterpreter extends ATNSimulator> {

public _interp: ATNInterpreter;
public interpreter: ATNInterpreter;

@@ -48,2 +49,5 @@ public addErrorListener(listener: BaseErrorListener<ATNInterpreter>): void;

public abstract get inputStream(): IntStream;
public abstract set inputStream(input: IntStream);
public abstract get grammarFileName(): string;

@@ -50,0 +54,0 @@ public abstract get ruleNames(): string[];

@@ -7,3 +7,3 @@ /*

import { RuleContext } from "../context/RuleContext.js";
import { RuleContext } from "../atn/RuleContext.js";
import { Interval } from "../misc/Interval.js";

@@ -25,3 +25,3 @@ import { Token } from "../Token.js";

*/
getParent(): ParseTree | null;
get parent(): ParseTree | null;

@@ -47,2 +47,9 @@ /**

/**
* Return the combined text of all leaf nodes. Does not get any
* off-channel tokens (if any) so won't return whitespace and
* comments if they are sent to parser on hidden channel.
*/
getText(): string;
/**
* Print out a whole tree, not just a node, in LISP format

@@ -49,0 +56,0 @@ * {@code (root child1 .. childN)}. Print just a node if this is a leaf.

@@ -7,3 +7,3 @@ /*

import { ParserRuleContext } from "../context/ParserRuleContext.js";
import { ParserRuleContext } from "../ParserRuleContext.js";
import { ErrorNode } from "./ErrorNode.js";

@@ -10,0 +10,0 @@ import { TerminalNode } from "./TerminalNode.js";

@@ -13,3 +13,3 @@ /*

public symbol: Token;
public parentCtx: ParseTree | null;
public get parent(): ParseTree | null;

@@ -16,0 +16,0 @@ public constructor(symbol: Token);

@@ -10,4 +10,4 @@ /*

import { LexerATNSimulator } from "../../atn/LexerATNSimulator.js";
import { BaseErrorListener } from "../../error/BaseErrorListener.js";
import { RecognitionException } from "../../error/RecognitionException.js";
import { BaseErrorListener } from "../../BaseErrorListener.js";
import { RecognitionException } from "../../RecognitionException.js";

@@ -14,0 +14,0 @@ export class XPathLexerErrorListener extends BaseErrorListener<LexerATNSimulator> {

@@ -9,2 +9,1 @@ /*

export * from "./arrayToString.js";
export * from "./Printer.js";
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