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

Generated TypeScript code contains errors #296

Open
jpilgrim opened this issue Aug 30, 2024 · 1 comment
Open

Generated TypeScript code contains errors #296

jpilgrim opened this issue Aug 30, 2024 · 1 comment
Labels
possible bug Could be a bug

Comments

@jpilgrim
Copy link

Versions.

  • Extension: v2.4.6
  • antlr4ng: 3.0.4

I have defined a grammar (the expression example from https://github.com/mike-lischke/antlr4ng) and let the extension generate the code.

Here is my .vscode/settings.json:

{
    "antlr4.generation": {
        "language": "TypeScript",
        "mode": "internal",
    }
}

I also have generated the code via antlr4ng-cli, i.e.

npx antlr4ng -Dlanguage=TypeScript -o src/gen -nolistener -Xexact-output-dir src/Expression.g4

The generated parsers are different. The version generated with the script has no compile errors, the other one has errors. The errors actually stem from the differences: The version generated by the extension sets some (unknown) exception properties, e.g.

catch (re) {
            if (re instanceof antlr.RecognitionException) {
+                localContext.exception = re;
                this.errorHandler.reportError(this, re);
                this.errorHandler.recover(this, re);
            } else {
                throw re;
            }
        }
@mike-lischke
Copy link
Owner

Looks like an older version of the antlr jar is being used in the error case. That needs to be updated.

@mike-lischke mike-lischke added the possible bug Could be a bug label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Could be a bug
Projects
None yet
Development

No branches or pull requests

2 participants