diff --git a/runtime/JavaScript/src/antlr4/Parser.d.ts b/runtime/JavaScript/src/antlr4/Parser.d.ts index 98fd0ed762..0e9c932cfc 100644 --- a/runtime/JavaScript/src/antlr4/Parser.d.ts +++ b/runtime/JavaScript/src/antlr4/Parser.d.ts @@ -19,6 +19,7 @@ export declare class Parser extends Recognizer { matchedEOF: boolean; buildParseTrees: boolean; printer?: Printer; + syntaxErrorsCount: number; constructor(input: TokenStream); match(ttype: number): Token; @@ -40,4 +41,5 @@ export declare class Parser extends Recognizer { setTokenStream(input: TokenStream): void; notifyErrorListeners(msg: string, offendingToken: Token, err: RecognitionException | undefined): void; getCurrentToken(): Token; + } diff --git a/runtime/JavaScript/src/antlr4/Parser.js b/runtime/JavaScript/src/antlr4/Parser.js index a2bdf5714d..4c434fd0db 100644 --- a/runtime/JavaScript/src/antlr4/Parser.js +++ b/runtime/JavaScript/src/antlr4/Parser.js @@ -288,6 +288,15 @@ export default class Parser extends Recognizer { this._input = input; } + /** + * Gets the number of syntax errors reported during parsing. This value is + * incremented each time {@link //notifyErrorListeners} is called. + */ + get syntaxErrorsCount() { + return this._syntaxErrors; + } + + /** * Match needs to return the current input symbol, which gets put * into the label for the associated token ref; e.g., x=ID.