Skip to content

Commit

Permalink
Fixed wrong type parameter for recognizers + error listeners.
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Lischke <mike.lischke@oracle.com>
  • Loading branch information
mike-lischke committed Sep 2, 2023
1 parent 09f25c7 commit 78be3bf
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 26 deletions.
3 changes: 1 addition & 2 deletions runtime/JavaScript/src/antlr4/Lexer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import Token from "./Token.js";
import TokenSource from "./TokenSource.js";
import TokenFactory from "./TokenFactory.js";

export declare abstract class Lexer extends Recognizer<number> implements TokenSource {
export declare abstract class Lexer extends Recognizer<LexerATNSimulator> implements TokenSource {

public static DEFAULT_MODE: number;
public static HIDDEN: number;

public _input: CharStream;
public _interp: LexerATNSimulator;
public text: string;
public line: number;
public column: number;
Expand Down
5 changes: 2 additions & 3 deletions runtime/JavaScript/src/antlr4/Parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ 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<Token> {
export declare abstract class Parser extends Recognizer<ParserATNSimulator> {
public static EOF: number;

private _parseListeners: ParseTreeListener[] | null;
protected _parseListeners: ParseTreeListener[] | null;

public _input: TokenStream;
public _ctx: ParserRuleContext;
public _interp: ParserATNSimulator;
public _errHandler: ErrorStrategy;
public matchedEOF: boolean;
public buildParseTrees: boolean;
Expand Down
6 changes: 4 additions & 2 deletions runtime/JavaScript/src/antlr4/Recognizer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import Vocabulary from "./Vocabulary.js";
import ATN from "./atn/ATN.js";
import ATNSimulator from "./atn/ATNSimulator.js";
import ErrorListener from "./error/ErrorListener.js";

export declare abstract class Recognizer<TSymbol> {
export declare abstract class Recognizer<ATNInterpreter extends ATNSimulator> {
public state: number;
public _interp: ATNInterpreter;

public get atn(): ATN;

Expand All @@ -17,7 +19,7 @@ export declare abstract class Recognizer<TSymbol> {
public abstract getVocabulary(): Vocabulary;

public removeErrorListeners(): void;
public addErrorListener(listener: ErrorListener<TSymbol>): void;
public addErrorListener(listener: ErrorListener<ATNInterpreter>): void;
}

export default Recognizer;
6 changes: 3 additions & 3 deletions runtime/JavaScript/src/antlr4/atn/LexerATNSimulator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
* can be found in the LICENSE.txt file in the project root.
*/

import Recognizer from "../Recognizer.js";
import ATNSimulator from "./ATNSimulator.js";
import ATN from "./ATN.js";
import PredictionContextCache from "./PredictionContextCache.js";
import DFA from "../dfa/DFA.js";
import CharStream from "../CharStream.js";
import Lexer from "../Lexer.js";

export declare class LexerATNSimulator implements ATNSimulator {
export declare class LexerATNSimulator extends ATNSimulator {

decisionToDFA: DFA[];

constructor(recog: Recognizer<number>, atn: ATN, decisionToDFA: DFA[], sharedContextCache: PredictionContextCache);
constructor(recog: Lexer, atn: ATN, decisionToDFA: DFA[], sharedContextCache: PredictionContextCache);
consume(input: CharStream): void;

}
Expand Down
6 changes: 3 additions & 3 deletions runtime/JavaScript/src/antlr4/atn/PrecedencePredicate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* can be found in the LICENSE.txt file in the project root.
*/

import Recognizer from "../Recognizer.js";
import Parser from "../Parser.js";
import RuleContext from "../context/RuleContext.js";
import SemanticContext from "./SemanticContext.js";

Expand All @@ -12,8 +12,8 @@ export declare class PrecedencePredicate extends SemanticContext {

public constructor(precedence?: number);

public evaluate(parser: Recognizer<unknown>, parserCallStack: RuleContext): boolean;
public evalPrecedence(parser: Recognizer<unknown>, parserCallStack: RuleContext): SemanticContext;
public evaluate(parser: Parser, parserCallStack: RuleContext): boolean;
public evalPrecedence(parser: Parser, parserCallStack: RuleContext): SemanticContext;

public compareTo(o: PrecedencePredicate): number;
public equals(other: unknown): boolean;
Expand Down
4 changes: 2 additions & 2 deletions runtime/JavaScript/src/antlr4/atn/Predicate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* can be found in the LICENSE.txt file in the project root.
*/

import Recognizer from "../Recognizer.js";
import Parser from "../Parser.js";
import RuleContext from "../context/RuleContext.js";
import SemanticContext from "./SemanticContext.js";

export declare class Predicate extends SemanticContext {
public constructor(ruleIndex: number, predIndex: number, isCtxDependent: boolean);

public evaluate(parser: Recognizer<unknown>, outerContext: RuleContext): boolean;
public evaluate(parser: Parser, outerContext: RuleContext): boolean;
public equals(obj: any): boolean;
public toString(): string;
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/JavaScript/src/antlr4/atn/SemanticContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* can be found in the LICENSE.txt file in the project root.
*/

import Recognizer from "../Recognizer.js";
import Parser from "../Parser.js";
import RuleContext from "../context/RuleContext.js";

export declare class SemanticContext {
public hashCode(): number;
public evaluate(parser: Recognizer<unknown>, outerContext: RuleContext): boolean;
public evaluate(parser: Parser, outerContext: RuleContext): boolean;
}

export default SemanticContext;
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import ErrorListener from "./ErrorListener";
import Recognizer from "../Recognizer";
import RecognitionException from "./RecognitionException";
import ATNSimulator from "../atn/ATNSimulator";

export declare class DiagnosticErrorListener<TSymbol> extends ErrorListener<TSymbol> {
syntaxError(recognizer: Recognizer<TSymbol>, offendingSymbol: TSymbol, line: number, column: number, msg: string, e: RecognitionException | undefined): void;
export declare class DiagnosticErrorListener<ATNInterpreter extends ATNSimulator> extends ErrorListener<ATNInterpreter> {
syntaxError<T>(recognizer: Recognizer<ATNInterpreter>, offendingSymbol: T, line: number, column: number, msg: string, e: RecognitionException | undefined): void;
}

export default DiagnosticErrorListener;
11 changes: 6 additions & 5 deletions runtime/JavaScript/src/antlr4/error/ErrorListener.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

import Recognizer from "../Recognizer.js";
import ATNConfigSet from "../atn/ATNConfigSet.js";
import ATNSimulator from "../atn/ATNSimulator.js";
import DFA from "../dfa/DFA.js";
import RecognitionException from "./RecognitionException.js";

export declare class ErrorListener<TSymbol> {
public syntaxError(recognizer: Recognizer<TSymbol>, offendingSymbol: TSymbol, line: number, column: number, msg: string, e: RecognitionException | undefined): void;
public reportAmbiguity(recognizer: Recognizer<TSymbol>, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: unknown, configs: ATNConfigSet): void;
public reportAttemptingFullContext(recognizer: Recognizer<TSymbol>, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: unknown, configs: ATNConfigSet): void;
public reportContextSensitivity(recognizer: Recognizer<TSymbol>, dfa: DFA, startIndex: number, stopIndex: number, prediction: number, configs: ATNConfigSet): void;
export declare class ErrorListener<ATNInterpreter extends ATNSimulator> {
public syntaxError<T>(recognizer: Recognizer<ATNInterpreter>, offendingSymbol: T, line: number, column: number, msg: string, e: RecognitionException | undefined): void;
public reportAmbiguity(recognizer: Recognizer<ATNInterpreter>, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: unknown, configs: ATNConfigSet): void;
public reportAttemptingFullContext(recognizer: Recognizer<ATNInterpreter>, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: unknown, configs: ATNConfigSet): void;
public reportContextSensitivity(recognizer: Recognizer<ATNInterpreter>, dfa: DFA, startIndex: number, stopIndex: number, prediction: number, configs: ATNConfigSet): void;
}

export default ErrorListener;
4 changes: 2 additions & 2 deletions runtime/JavaScript/src/antlr4/tree/TerminalNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ParserRuleContext from "../context/ParserRuleContext.js";
import ParseTree from "./ParseTree.js";
import Token from "../Token.js";
import Interval from "../misc/Interval.js";
import Recognizer from "../Recognizer.js";
import Parser from "../Parser.js";

export declare class TerminalNode extends ParseTree {
public symbol: Token;
Expand All @@ -20,7 +20,7 @@ export declare class TerminalNode extends ParseTree {
public getPayload(): Token;
public getSourceInterval(): Interval;
public getChildCount(): number;
public toStringTree(parser: Recognizer<unknown> | null): string;
public toStringTree(parser: Parser | null): string;
public toString(): string;
public toStringTree(): string;

Expand Down

0 comments on commit 78be3bf

Please sign in to comment.