11// SPDX-FileCopyrightText: Copyright (c) 2024-2025 Objectionary.com
22// SPDX-License-Identifier: MIT
33
4- import { Token , CommonToken , Lexer , CharStream } from "antlr4ts " ;
5- import { EoLexer } from "./parser/EoLexer" ;
6- import { EoParser } from "./parser/EoParser" ;
4+ import { Token , CommonToken , Lexer , CharStream } from "antlr4 " ;
5+ import EoLexer from "./parser/EoLexer" ;
6+ import EoParser from "./parser/EoParser" ;
77
88/**
99 * Custom lexer that wraps EoLexer to handle indentation-based TAB/UNTAB tokens
@@ -42,7 +42,7 @@ export class IndentationLexer extends Lexer {
4242 */
4343 private emitIndent ( shift : number ) : void {
4444 for ( let i = 0 ; i < shift ; i ++ ) {
45- this . emitToken ( IndentationLexer . TAB ) ;
45+ this . emitIndentationToken ( IndentationLexer . TAB ) ;
4646 }
4747 }
4848
@@ -53,7 +53,7 @@ export class IndentationLexer extends Lexer {
5353 */
5454 private emitDedent ( shift : number ) : void {
5555 for ( let i = 0 ; i < shift ; i ++ ) {
56- this . emitToken ( IndentationLexer . UNTAB ) ;
56+ this . emitIndentationToken ( IndentationLexer . UNTAB ) ;
5757 }
5858 }
5959
@@ -63,10 +63,10 @@ export class IndentationLexer extends Lexer {
6363 * @param type - Token type (must be IndentationLexer.TAB or IndentationLexer.UNTAB)
6464 * @returns Void
6565 */
66- private emitToken ( type : number ) {
67- const tkn = new CommonToken ( type , type === IndentationLexer . TAB ? "TAB" : "UNTAB" ) ;
66+ private emitIndentationToken ( type : number ) {
67+ const tkn = new CommonToken ( [ this . wrapped , this . _input ] , type , Token . DEFAULT_CHANNEL , 0 , 0 ) ;
6868 tkn . line = this . wrapped . line ;
69- tkn . charPositionInLine = 0 ;
69+ tkn . column = 0 ;
7070 this . tokens . push ( tkn ) ;
7171 }
7272
@@ -176,10 +176,7 @@ export class IndentationLexer extends Lexer {
176176 get ruleNames ( ) : string [ ] {
177177 return this . wrapped . ruleNames ;
178178 }
179- get serializedATN ( ) : string {
179+ get serializedATN ( ) : number [ ] {
180180 return this . wrapped . serializedATN ;
181181 }
182- get vocabulary ( ) : any {
183- return this . wrapped . vocabulary ;
184- }
185182}
0 commit comments