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

Ported the JavaScript version of ECMAScript.g4 to TypeScript #2556

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

montyz
Copy link
Contributor

@montyz montyz commented Mar 23, 2022

No description provided.

@teverett
Copy link
Member

Thanks @montyz . @KvanTTT , @kaby76 all good to pull this PR?

@KvanTTT
Copy link
Member

KvanTTT commented Mar 24, 2022

I have no objection but I suggest improving JavaScript.g4 since ECMAScript.g4 is outdated.

@kaby76
Copy link
Contributor

kaby76 commented Mar 24, 2022

I think this is fine.

We've tried pretty hard to move the grammars to a "target agnostic" syntax for the grammars, but this is a grammar that was never updated. Instead, target specific code is place in the grammar using @members methods/functions that are emitted in the generated parser itself.

But, in reality, Antlr4 doesn't really have a "target agnostic" solution in which we have one common grammar that wraps all the target specific code in a function call, which is then placed in a base class (or functions) for each target, outside the grammar. It's really "pseudo-target agnostic" because it doesn't work for all targets.

I've tried to explain this in Antlr4 Issue 3508. In my opinion, this is a fundamental, high-priority problem with Antlr that needs to be fixed.

Serendipitously, I stubbled on a grammar that had a "$parser.foobar()" referenced in an action, and found that Antlr already converts "$parser." into the target specific syntax for all but Cpp and PHP! There is currently no equivalent for a "$lexer" reference, so that would also be needed. However, I would prefer to see references to the parser or lexer as just "$this", dispensing with the distinction. I sometimes find I need to move rules around between lexer and parser.

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

Successfully merging this pull request may close these issues.

4 participants