Skip to content

[JavaScript-runtime] Export ATN transitions with types #4805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ATNState } from '../state/ATNState';
import { Transition } from '../transition/Transition';

export declare class AbstractPredicateTransition extends Transition {
constructor(target: ATNState);
}
11 changes: 11 additions & 0 deletions runtime/JavaScript/src/antlr4/atn/PrecedencePredicate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { HashCode } from '../misc/HashCode';
import type { SemanticContext } from './SemanticContext';

export declare class PrecedencePredicate extends SemanticContext {
constructor(precedence: number);

compareTo(other: SemanticContext): number;
updateHashCode(hash: HashCode): void;
equals(obj: any): boolean;
toString(): string;
}
18 changes: 18 additions & 0 deletions runtime/JavaScript/src/antlr4/atn/Predicate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ParserRuleContext } from '../context/ParserRuleContext';
import type { HashCode } from '../misc/HashCode';
import type { Recognizer } from '../Recognizer';
import type { Token } from '../Token';
import type { SemanticContext } from './SemanticContext';

export declare class Predicate extends SemanticContext {
ruleIndex: number;
predIndex: number;
isCtxDependent: boolean;

constructor(ruleIndex: number, predIndex: number, isCtxDependent: boolean);

evaluate(parser: Recognizer<Token>, outerContext: ParserRuleContext): boolean;
updateHashCode(hash: HashCode): void;
equals(obj: any): boolean;
toString(): string;
}
12 changes: 12 additions & 0 deletions runtime/JavaScript/src/antlr4/atn/SemanticContext.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { ParserRuleContext } from '../context/ParserRuleContext';
import type { Recognizer } from '../Recognizer';
import type { Token } from '../Token';

export declare class SemanticContext {
hashCode(): number;
evaluate(parser: Recognizer<Token>, outerContext: ParserRuleContext): boolean;
evalPrecedence(parser: Recognizer<Token>, outerContext: ParserRuleContext): SemanticContext;

static andContext(a: SemanticContext, b: SemanticContext): SemanticContext;
static orContext(a: SemanticContext, b: SemanticContext): SemanticContext;
}
5 changes: 4 additions & 1 deletion runtime/JavaScript/src/antlr4/atn/index.d.ts
Original file line number Diff line number Diff line change
@@ -6,4 +6,7 @@ export * from './LexerATNSimulator';
export * from './ParserATNSimulator';
export * from './PredictionMode';
export * from './PredictionContextCache';

export * from './PrecedencePredicate'
export * from './Predicate'
export * from './SemanticContext'
export * from './AbstractPredicateTransition'
1 change: 1 addition & 0 deletions runtime/JavaScript/src/antlr4/index.d.cts
Original file line number Diff line number Diff line change
@@ -19,3 +19,4 @@ export * from "./state";
export * from "./error";
export * from "./utils";
export * from "./TokenStreamRewriter";
export * from "./transition"
17 changes: 16 additions & 1 deletion runtime/JavaScript/src/antlr4/index.node.js
Original file line number Diff line number Diff line change
@@ -47,6 +47,20 @@ import TerminalNode from "./tree/TerminalNode.js"
import arrayToString from "./utils/arrayToString.js"
import TokenStreamRewriter from './TokenStreamRewriter.js';
import InputMismatchException from "./error/InputMismatchException.js"
import Transition from "./transition/Transition.js"
import ActionTransition from './transition/ActionTransition.js';
import AtomTransition from './transition/AtomTransition.js';
import EpsilonTransition from './transition/EpsilonTransition.js';
import NotSetTransition from './transition/NotSetTransition.js';
import PrecedencePredicateTransition from './transition/PrecedencePredicateTransition.js';
import PredicateTransition from './transition/PredicateTransition.js';
import RangeTransition from './transition/RangeTransition.js';
import RuleTransition from './transition/RuleTransition.js';
import SetTransition from './transition/SetTransition.js';
import WildcardTransition from './transition/WildcardTransition.js';
import RuleStartState from './state/RuleStartState.js';
import RuleStopState from './state/RuleStopState.js';


export default {
atn, dfa, context, misc, tree, error, Token, CommonToken, CharStreams, CharStream, InputStream, FileStream, CommonTokenStream, Lexer, Parser,
@@ -58,5 +72,6 @@ export {
RuleNode, TerminalNode, ParseTreeWalker, RuleContext, ParserRuleContext, Interval, IntervalSet,
PredictionMode, LL1Analyzer, ParseTreeListener, ParseTreeVisitor, ATN, ATNDeserializer, PredictionContextCache, LexerATNSimulator, ParserATNSimulator, DFA,
RecognitionException, NoViableAltException, FailedPredicateException, ErrorListener, DiagnosticErrorListener, BailErrorStrategy, DefaultErrorStrategy,
arrayToString, TokenStreamRewriter, InputMismatchException
arrayToString, TokenStreamRewriter, InputMismatchException, Transition, ActionTransition, AtomTransition, EpsilonTransition, NotSetTransition,
PrecedencePredicateTransition, PredicateTransition, RangeTransition, RuleTransition, SetTransition, WildcardTransition, RuleStartState, RuleStopState
}
17 changes: 16 additions & 1 deletion runtime/JavaScript/src/antlr4/index.web.js
Original file line number Diff line number Diff line change
@@ -46,6 +46,20 @@ import TerminalNode from "./tree/TerminalNode.js"
import arrayToString from "./utils/arrayToString.js"
import TokenStreamRewriter from './TokenStreamRewriter.js';
import InputMismatchException from "./error/InputMismatchException.js"
import Transition from "./transition/Transition.js"
import ActionTransition from './transition/ActionTransition.js';
import AtomTransition from './transition/AtomTransition.js';
import EpsilonTransition from './transition/EpsilonTransition.js';
import NotSetTransition from './transition/NotSetTransition.js';
import PrecedencePredicateTransition from './transition/PrecedencePredicateTransition.js';
import PredicateTransition from './transition/PredicateTransition.js';
import RangeTransition from './transition/RangeTransition.js';
import RuleTransition from './transition/RuleTransition.js';
import SetTransition from './transition/SetTransition.js';
import WildcardTransition from './transition/WildcardTransition.js';
import RuleStartState from './state/RuleStartState.js';
import RuleStopState from './state/RuleStopState.js';


export default {
atn, dfa, context, misc, tree, error, Token, CommonToken, CharStreams, CharStream, InputStream, CommonTokenStream, Lexer, Parser,
@@ -57,5 +71,6 @@ export {
RuleNode, TerminalNode, ParseTreeWalker, RuleContext, ParserRuleContext, Interval, IntervalSet,
PredictionMode, LL1Analyzer, ParseTreeListener, ParseTreeVisitor, ATN, ATNDeserializer, PredictionContextCache, LexerATNSimulator, ParserATNSimulator, DFA,
RecognitionException, NoViableAltException, FailedPredicateException, ErrorListener, DiagnosticErrorListener, BailErrorStrategy, DefaultErrorStrategy,
arrayToString, TokenStreamRewriter, InputMismatchException
arrayToString, TokenStreamRewriter, InputMismatchException, Transition, ActionTransition, AtomTransition, EpsilonTransition, NotSetTransition,
PrecedencePredicateTransition, PredicateTransition, RangeTransition, RuleTransition, SetTransition, WildcardTransition, RuleStartState, RuleStopState
}
9 changes: 9 additions & 0 deletions runtime/JavaScript/src/antlr4/misc/HashCode.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export declare class HashCode {
count: number;
hash: number;

update(): void;
finish(): number;

static hashStuff(): number;
}
2 changes: 1 addition & 1 deletion runtime/JavaScript/src/antlr4/misc/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './Interval'
export * from './IntervalSet';

export * from './HashCode'
13 changes: 13 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/ActionTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ATNState } from '../state/ATNState';
import { Transition } from './Transition';

export declare class ActionTransition extends Transition {
serializationType: number;
ruleIndex: number;
actionIndex: number;
isCtxDependent: boolean;
constructor(target: ATNState, ruleIndex: number, actionIndex: number, isCtxDependent: boolean)

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
10 changes: 10 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/AtomTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ATNState } from '../state/ATNState';
import type { Transition } from './Transition';

export declare class AtomTransition extends Transition {
serializationType: number;
constructor(target: ATNState, label: number)

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
11 changes: 11 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/EpsilonTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ATNState } from '../state/ATNState';
import { Transition } from './Transition';

export declare class EpsilonTransition extends Transition {
serializationType: number;
outermostPrecedenceReturn: number;
constructor(target: ATNState, outermostPrecendenceReturn: number);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
11 changes: 11 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/NotSetTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { IntervalSet } from '../misc/IntervalSet';
import type { ATNState } from '../state/ATNState';
import { SetTransition } from './SetTransition';

export declare class NotSetTransition extends SetTransition {
serializationType: number;
constructor(target: ATNState, set: IntervalSet);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AbstractPredicateTransition } from '../atn/AbstractPredicateTransition';
import type { PrecedencePredicate } from '../atn/PrecedencePredicate';
import type { ATNState } from '../state/ATNState';

export declare class PrecedencePredicateTransition extends AbstractPredicateTransition {
serializationType: number;
precedence: number;
constructor(target: ATNState, precedence: number);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
getPredicate(): PrecedencePredicate;
toString(): string;
}
15 changes: 15 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/PredicateTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AbstractPredicateTransition } from '../atn/AbstractPredicateTransition';
import type { Predicate } from '../atn/Predicate';
import type { ATNState } from '../state/ATNState';

export declare class PredicateTransition extends AbstractPredicateTransition {
serializationType: number;
ruleIndex: number;
predIndex: number
isCtxDependent: boolean;
constructor(target: ATNState, ruleIndex: number, predIndex: number, isCtxDependent: boolean);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
getPredicate(): Predicate
toString(): string;
}
12 changes: 12 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/RangeTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { ATNState } from '../state/ATNState';
import type { Transition } from './Transition';

export declare class RangeTransition extends Transition {
serializationType: number;
start: number;
stop: number;
constructor(target: ATNState, start: number, stop: number);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
13 changes: 13 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/RuleTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ATNState } from '../state/ATNState';
import type { Transition } from './Transition';

export declare class RuleTransition extends Transition {
serializationType: number;
ruleIndex: number;
precedence: number;
followState: ATNState;

constructor(ruleStart: ATNState, ruleIndex: number, precedence: number, followState: ATNState);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
}
12 changes: 12 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/SetTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { IntervalSet } from '../misc/IntervalSet';
import type { ATNState } from '../state/ATNState';
import type { Transition } from './Transition';

export declare class SetTransition extends Transition {
serializationType: number

constructor(target: ATNState, set: IntervalSet);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
21 changes: 21 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/Transition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { IntervalSet } from '../misc/IntervalSet';
import type { ATNState } from '../state/ATNState';

export declare class Transition {
target: ATNState;
isEpsilon: boolean;
label: IntervalSet;

static EPSILON: number;
static RANGE: number;
static RULE: number;
static PREDICATE: number;
static ATOM: number;
static ACTION: number;
static SET: number;
static NOT_SET: number;
static WILDCARD: number;
static PRECEDENCE: number;
static serializationNames: string[];
static serializationTypes: Record<string, number>;
}
10 changes: 10 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/WildcardTransition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { ATNState } from '../state/ATNState';
import type { Transition } from './Transition';

export declare class WildcardTransition extends Transition {
serializationType: number;
constructor(target: ATNState);

matches(symbol: number, minVocabSymbol: number, maxVocabSymbol: number): boolean;
toString(): string;
}
11 changes: 11 additions & 0 deletions runtime/JavaScript/src/antlr4/transition/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export * from './ActionTransition'
export * from './AtomTransition'
export * from './EpsilonTransition'
export * from './NotSetTransition'
export * from './PrecedencePredicateTransition'
export * from './PredicateTransition'
export * from './RangeTransition'
export * from './RuleTransition'
export * from './SetTransition'
export * from './Transition'
export * from './WildcardTransition'