Skip to content

Commit b4c12ec

Browse files
Phlosioneerericvergnaud
authored andcommitted
Add parse listener methods to Parser typescript
This PR adds the four parse listener methods. The `_parseListeners` field could also be set to `ParseTreeListener[]`, but it would _technically_ be a breaking change. I chose to use `ParseTreeListener` instead of `any` in these methods because parse listeners cannot actually be `any`; their functions are called without checking if they're defined. The current ParseTreeListener interface is the minimum requirement to avoid exceptions. Signed-off-by: Phlosioneer <[email protected]>
1 parent 69cfd8e commit b4c12ec

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runtime/JavaScript/src/antlr4/Parser.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {ParserATNSimulator} from "./atn";
66
import {Token} from "./Token";
77
import {ParserRuleContext} from "./context";
88
import {Printer} from "./utils";
9+
import {ParseTreeListener} from "./tree";
910

1011
export declare class Parser extends Recognizer<Token> {
1112

@@ -24,6 +25,10 @@ export declare class Parser extends Recognizer<Token> {
2425
constructor(input: TokenStream);
2526
match(ttype: number): Token;
2627
matchWildcard(): Token;
28+
getParseListeners(): ParseTreeListener[];
29+
addParseListener(listener: ParseTreeListener): void;
30+
removeParseListener(listener: ParseTreeListener): void;
31+
removeParseListeners(): void;
2732
consume(): Token;
2833
enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number): void;
2934
exitRule() : void;

0 commit comments

Comments
 (0)