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

Incorrect code generation for lexer #516

Open
HectorPeeters opened this issue Nov 17, 2021 · 1 comment
Open

Incorrect code generation for lexer #516

HectorPeeters opened this issue Nov 17, 2021 · 1 comment

Comments

@HectorPeeters
Copy link

When using antlr4ts (version 0.4.0-alpha.4) to generate a parser and lexer for the XQuery 3.1 language, the generated code includes some invalid typescript:
private int bracesInside = 0;

This can be fixed by changing it to:
private bracesInside: number = 0;

The command I used to generate the typescript code is:
antlr4ts src/parsing/XQueryLexer.g4 src/parsing/XQueryParser.g4 -visitor

And the g4 files can be found here: https://github.com/xqdoc/xqdoc/tree/master/src/main/antlr4/org/xqdoc

This is a snippet from the generated typescript code.

...
    ///
    /// FIELDS
    ///

    // for counting braces inside string literals
    private int bracesInside = 0;

constructor(input: CharStream) {
    super(input);
    this._interp = new LexerATNSimulator(XQueryLexer._ATN, this);
}
...

I tried to fixing the generation myself first but couldn't find the exact location in the codebase where bracesInside gets created.

@maxabrahamsson
Copy link

I am experiencing the same problem.

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

2 participants