diff --git a/benchmark/TestPerformance.ts b/benchmark/TestPerformance.ts index 7b3df428..53043477 100644 --- a/benchmark/TestPerformance.ts +++ b/benchmark/TestPerformance.ts @@ -1665,7 +1665,7 @@ class DescriptiveErrorListener implements ParserErrorListener { static INSTANCE: DescriptiveErrorListener = new DescriptiveErrorListener(); @Override - syntaxError(recognizer: Recognizer, offendingSymbol: T, line: number, charPositionInLine: number, msg: string, e: RecognitionException): void { + syntaxError(recognizer: Recognizer, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException): void { if (!TestPerformance.REPORT_SYNTAX_ERRORS) { return; } @@ -1685,7 +1685,7 @@ class DescriptiveLexerErrorListener implements ANTLRErrorListener { static INSTANCE: DescriptiveLexerErrorListener = new DescriptiveLexerErrorListener(); @Override - syntaxError(recognizer: Recognizer, offendingSymbol: T, line: number, charPositionInLine: number, msg: string, e: RecognitionException): void { + syntaxError(recognizer: Recognizer, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException): void { if (!TestPerformance.REPORT_SYNTAX_ERRORS) { return; } @@ -1702,11 +1702,11 @@ class DescriptiveLexerErrorListener implements ANTLRErrorListener { } class SummarizingDiagnosticErrorListener extends DiagnosticErrorListener { - private _sllConflict: BitSet; + private _sllConflict: BitSet | undefined; private _sllConfigs: ATNConfigSet; @Override - reportAmbiguity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: BitSet, configs: ATNConfigSet): void { + reportAmbiguity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: BitSet | undefined, configs: ATNConfigSet): void { if (TestPerformance.COMPUTE_TRANSITION_STATS && TestPerformance.DETAILED_DFA_STATE_STATS) { let sllPredictions: BitSet = this.getConflictingAlts(this._sllConflict, this._sllConfigs); let sllPrediction: number = sllPredictions.nextSetBit(0); @@ -1729,7 +1729,7 @@ class SummarizingDiagnosticErrorListener extends DiagnosticErrorListener { } @Override - reportAttemptingFullContext(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: BitSet, conflictState: SimulatorState): void { + reportAttemptingFullContext(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: BitSet | undefined, conflictState: SimulatorState): void { this._sllConflict = conflictingAlts; this._sllConfigs = conflictState.s0.configs; if (!TestPerformance.REPORT_FULL_CONTEXT) { diff --git a/package.json b/package.json index 9c9046fb..a18003df 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "source-map-support": "^0.4.3", "std-mocks": "^1.0.1", "typedoc": "^0.5.1", - "typescript": "^2.1.0" + "typescript": "^2.4.1" }, "dependencies": {} } diff --git a/src/Decorators.ts b/src/Decorators.ts index 17fbcda0..40c7a6c8 100644 --- a/src/Decorators.ts +++ b/src/Decorators.ts @@ -6,13 +6,13 @@ export function NotNull( target: any, propertyKey: PropertyKey, - propertyDescriptor?: PropertyDescriptor) { + propertyDescriptor?: PropertyDescriptor | number) { } export function Nullable( target: any, propertyKey: PropertyKey, - propertyDescriptor?: PropertyDescriptor) { + propertyDescriptor?: PropertyDescriptor | number) { } export function Override(target: any, diff --git a/src/DiagnosticErrorListener.ts b/src/DiagnosticErrorListener.ts index e401fa0c..1af2e033 100644 --- a/src/DiagnosticErrorListener.ts +++ b/src/DiagnosticErrorListener.ts @@ -33,7 +33,10 @@ import { BitSet } from './misc/BitSet'; import { DFA } from './dfa/DFA'; import { Parser } from './Parser'; import { ParserErrorListener } from './ParserErrorListener'; +import { RecognitionException } from './RecognitionException'; +import { Recognizer } from './Recognizer'; import { SimulatorState } from './atn/SimulatorState'; +import { Token } from './Token'; import { Override, NotNull } from "./Decorators"; import { Interval } from "./misc/Interval"; import { asIterable } from './misc/Stubs'; @@ -51,6 +54,18 @@ export class DiagnosticErrorListener implements ParserErrorListener { this.exactOnly = exactOnly; } + @Override + syntaxError( + /*@NotNull*/ recognizer: Recognizer, + offendingSymbol: T | undefined, + line: number, + charPositionInLine: number, + /*@NotNull*/ + msg: string, + e: RecognitionException | undefined): void + { + } + @Override reportAmbiguity(@NotNull recognizer: Parser, @NotNull dfa: DFA, diff --git a/src/Recognizer.ts b/src/Recognizer.ts index 9431e7cc..a7d48507 100644 --- a/src/Recognizer.ts +++ b/src/Recognizer.ts @@ -70,7 +70,7 @@ export abstract class Recognizer { } intermediateResult.set("EOF", Token.EOF); - result = Object.freeze(intermediateResult); + result = intermediateResult; Recognizer.tokenTypeMapCache.set(vocabulary, result); } @@ -91,7 +91,7 @@ export abstract class Recognizer { let result: ReadonlyMap | undefined = Recognizer.ruleIndexMapCache.get(ruleNames); if (result == null) { - result = Object.freeze(Utils.toMap(ruleNames)); + result = Utils.toMap(ruleNames); Recognizer.ruleIndexMapCache.set(ruleNames, result); } diff --git a/src/tree/ParseTreeWalker.ts b/src/tree/ParseTreeWalker.ts index 3c558564..98611a96 100644 --- a/src/tree/ParseTreeWalker.ts +++ b/src/tree/ParseTreeWalker.ts @@ -12,7 +12,7 @@ import { RuleNode } from "./RuleNode"; import { ParserRuleContext } from "../ParserRuleContext"; export class ParseTreeWalker { - walk(listener: ParseTreeListener, t: ParseTree): void { + walk(listener: T, t: ParseTree): void { let nodeStack: ParseTree[] = []; let indexStack: number[] = []; diff --git a/src/tree/xpath/XPathLexerErrorListener.ts b/src/tree/xpath/XPathLexerErrorListener.ts index c889d342..4e2d11c7 100644 --- a/src/tree/xpath/XPathLexerErrorListener.ts +++ b/src/tree/xpath/XPathLexerErrorListener.ts @@ -12,7 +12,7 @@ import { RecognitionException } from "../../RecognitionException"; export class XPathLexerErrorListener implements ANTLRErrorListener { @Override - syntaxError(recognizer: Recognizer, offendingSymbol: T, + syntaxError(recognizer: Recognizer, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException): void { } diff --git a/tool/test/org/antlr/v4/test/runtime/typescript/TypeScript.test.stg b/tool/test/org/antlr/v4/test/runtime/typescript/TypeScript.test.stg index 58619f2d..0da064a7 100644 --- a/tool/test/org/antlr/v4/test/runtime/typescript/TypeScript.test.stg +++ b/tool/test/org/antlr/v4/test/runtime/typescript/TypeScript.test.stg @@ -363,7 +363,7 @@ export class LeafListener implements TListener { >> WalkListener(s) ::= << -ParseTreeWalker.DEFAULT.walk(new LeafListener(), ); +ParseTreeWalker.DEFAULT.walk\(new LeafListener(), ); >> TreeNodeWithAltNumField(X) ::= <<