diff --git a/src/Lexer.ts b/src/Lexer.ts index 2afa7c6..bbffc80 100644 --- a/src/Lexer.ts +++ b/src/Lexer.ts @@ -110,7 +110,7 @@ export abstract class Lexer extends Recognizer implements Tok /** * Once we see EOF on char stream, next token will be EOF. - * If you have DONE : EOF ; then you see DONE EOF. + * If you have DONE : EOF ; then you see DONE EOF. */ #hitEOF = false; @@ -127,6 +127,8 @@ export abstract class Lexer extends Recognizer implements Tok public constructor(input: CharStream, options?: Partial) { super(); + + // Override the default options with the provided options. this.options = { ...this.options, ...options }; this.#input = input; this.#factory = CommonTokenFactory.DEFAULT; @@ -313,7 +315,7 @@ export abstract class Lexer extends Recognizer implements Tok */ public getAllTokens(): Token[] { const tokens = []; - let t = this.nextToken()!; + let t = this.nextToken(); while (t.type !== Token.EOF) { tokens.push(t); t = this.nextToken()!; diff --git a/src/tree/AbstractParseTreeVisitor.ts b/src/tree/AbstractParseTreeVisitor.ts index cbd4818..8c34cf6 100644 --- a/src/tree/AbstractParseTreeVisitor.ts +++ b/src/tree/AbstractParseTreeVisitor.ts @@ -4,7 +4,6 @@ * can be found in the LICENSE.txt file in the project root. */ -import { ParserRuleContext } from "../ParserRuleContext.js"; import { ErrorNode } from "./ErrorNode.js"; import { ParseTree } from "./ParseTree.js"; import { ParseTreeVisitor } from "./ParseTreeVisitor.js"; @@ -15,7 +14,7 @@ export abstract class AbstractParseTreeVisitor implements ParseTreeVisitor return tree.accept(this); } - public visitChildren(node: ParserRuleContext): T | null { + public visitChildren(node: ParseTree): T | null { let result = this.defaultResult(); const n = node.getChildCount(); for (let i = 0; i < n; i++) { @@ -45,7 +44,7 @@ export abstract class AbstractParseTreeVisitor implements ParseTreeVisitor return null; } - protected shouldVisitNextChild(_node: ParserRuleContext, _currentResult: T | null): boolean { + protected shouldVisitNextChild(_node: ParseTree, _currentResult: T | null): boolean { return true; } diff --git a/src/tree/ParseTreeVisitor.ts b/src/tree/ParseTreeVisitor.ts index 9abd332..ca82a40 100644 --- a/src/tree/ParseTreeVisitor.ts +++ b/src/tree/ParseTreeVisitor.ts @@ -5,9 +5,8 @@ */ import { type ErrorNode } from "./ErrorNode.js"; -import { type TerminalNode } from "./TerminalNode.js"; import { type ParseTree } from "./ParseTree.js"; -import { type ParserRuleContext } from "../ParserRuleContext.js"; +import { type TerminalNode } from "./TerminalNode.js"; /** * This interface defines the basic notion of a parse tree visitor. Generated @@ -34,7 +33,7 @@ export interface ParseTreeVisitor { * @param node The {@link RuleNode} whose children should be visited. * @returns The result of visiting the children of the node. */ - visitChildren(node: ParserRuleContext): T | null; + visitChildren(node: ParseTree): T | null; /** * Visit a terminal node, and return a user-defined result of the operation. diff --git a/src/tree/pattern/StartRuleDoesNotConsumeFullPatternError.ts b/src/tree/pattern/StartRuleDoesNotConsumeFullPatternError.ts index 9d7adff..54fdf2d 100644 --- a/src/tree/pattern/StartRuleDoesNotConsumeFullPatternError.ts +++ b/src/tree/pattern/StartRuleDoesNotConsumeFullPatternError.ts @@ -6,6 +6,5 @@ // Fixes https://github.com/antlr/antlr4/issues/413 // "Tree pattern compilation doesn't check for a complete parse" -// eslint-disable-next-line @typescript-eslint/naming-convention export class StartRuleDoesNotConsumeFullPatternError extends Error { };