From b4c12ece2c6e44f4faf1f30c258e52c8142c2dcc Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Sat, 16 Mar 2024 16:54:16 -0400 Subject: [PATCH] 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 --- runtime/JavaScript/src/antlr4/Parser.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/JavaScript/src/antlr4/Parser.d.ts b/runtime/JavaScript/src/antlr4/Parser.d.ts index 0e9c932cfc..74b54420d5 100644 --- a/runtime/JavaScript/src/antlr4/Parser.d.ts +++ b/runtime/JavaScript/src/antlr4/Parser.d.ts @@ -6,6 +6,7 @@ import {ParserATNSimulator} from "./atn"; import {Token} from "./Token"; import {ParserRuleContext} from "./context"; import {Printer} from "./utils"; +import {ParseTreeListener} from "./tree"; export declare class Parser extends Recognizer { @@ -24,6 +25,10 @@ export declare class Parser extends Recognizer { constructor(input: TokenStream); match(ttype: number): Token; matchWildcard(): Token; + getParseListeners(): ParseTreeListener[]; + addParseListener(listener: ParseTreeListener): void; + removeParseListener(listener: ParseTreeListener): void; + removeParseListeners(): void; consume(): Token; enterRule(localctx: ParserRuleContext, state: number, ruleIndex: number): void; exitRule() : void;