Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript-lexer: generated typescript lexer imports 'DecisionState' but the antlr4 node-module does not export #4809

Open
foofighter2146 opened this issue Mar 30, 2025 · 1 comment

Comments

@foofighter2146
Copy link

Bug

Antlr 4.13.2 generates from a lexer grammar a typescript lexer which imports 'DecisionState':

import {
	ATN,
	ATNDeserializer,
	CharStream,
	DecisionState, DFA,
	Lexer,
	LexerATNSimulator,
	RuleContext,
	PredictionContextCache,
	Token
} from "antlr4";

But the antlr4 node-module (version 4.13.2) does not export 'DecisionState'. This can be verified by executing a small javascript:

import * as antlr4 from 'antlr4';
console.log(Object.keys(antlr4));

The output does not contain 'DecisionState'.

Workaround

Because DecisionState is only used as type decleration in

static DecisionsToDFA = CalcLexer._ATN.decisionToState.map( (ds: DecisionState, index: number) => new DFA(ds, index) );

it can be simply removed from the typescript lexer file by executing a post processor.

Suggestion for a Fix

This issue could be fixed either by exporting 'DecisionState' in the antlr4 node-module or removing the explicit usage in the generated lexer file.

@foofighter2146
Copy link
Author

Same for parser. Here are the exports for 'TokenStream' and 'DecisionState' both missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant