-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Javascript: migrate prototypical root modules to ES6 #2787
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
Conversation
fix: dont wrap class in an object for export use const/let for better scoping use jsdoc
fix: dont wrap class in an object for export use const for better scoping use jsdoc
fix: dont wrap class in an object for export fix: annotate adjustSeekIndex with Number type to avoid warning use const for better scoping use jsdoc
refactored FileStream.js to use es6 classes fix: dont wrap class in an object for export use const for better scoping use jsdoc
use const/let for better scoping
refactored Lexer.js to use es6 classes fix: dont wrap class in object for exporting use const/let for better scoping use jsdoc
fix: dont wrap export in object use const/let for better scoping use jsdoc
fix: dont wrap export in object use const/let for better scoping use jsdoc
refactored ParserRuleContext.js to use es6 classes fix: dont wrap export in object use const/let for better scoping use jsdoc
use const/let for better scoping use jsdoc
use const/let for better scoping use jsdoc
use const/let for better scoping use jsdoc
fix: no need to return this in constructor
@parrt blessed |
Hey, quite a massive investment!
|
Not entirely. The templates still modify the prototype directly. As mentioned in the PR description I tried to avoid changing too much at the same time so I changed the I guess that would be for another PR 😅
I would not aim for this right now since import style is experimental in nodejs. This means that you would need a transpiler for using the code even in node.js which I think defeats the purpose. |
Fair enough, I've been using it with node for a few years now, and stopped noticing the above because I need a compiler for JSX anyway... |
I step by to say a word of appreciation, this investment is huge step forward for JavaScript target! Making it easier to use antlr4 with modern front-end toolbox out of the box. So far we needed to maintain our own pre-compiled fork of antlr4 for web purposes, with those changes + published antlr4 for web package, we'd be able to drop maintenance of the fork :) |
@piotrl thanks for that. It doesnt happen often that someone stops by to say thanks on an open source project 😃 .
Why not take a step forward and help make it even better 😉 . I am pretty sure there is lots of thigns that you could contribute to the project. On another topic ...
@ericvergnaud I have been trying to get this done but so far I have failed miserably. The problem that I am facing is that the template seems to assume that it is possible to have nested classes, which is not in Javascript. That means that for example here, it is not possible to "finish" the class declaration because another class starts in |
I’m a bit busy for the next 2 weeks, maybe shout back then? I’ll look into it.
… Le 17 avr. 2020 à 23:13, Camilo Roca ***@***.***> a écrit :
@piotrl <https://github.com/piotrl> thanks for that. It doesnt happen often that someone stops by to say thanks on an open source project 😃 .
So far we needed to maintain our own pre-compiled fork of antlr4 for web purposes, with those changes + published antlr4 for web package, we'd be able to drop maintenance of the fork :)
Why not take a step forward and help make it even better 😉 . I am pretty sure there is lots of thigns that you could contribute to the project.
On another topic ...
Not entirely. The templates still modify the prototype directly. As mentioned in the PR description I tried to avoid changing too much at the same time so I changed the function ... to be class extends ... but the rest is still the same.
@ericvergnaud <https://github.com/ericvergnaud> I have been trying to get this done but so far I have failed miserably. The problem that I am facing is that the template seems to assume that it is possible to have nested classes, which is not in Javascript. That means that for example here <https://github.com/antlr/antlr4/blob/master/tool/resources/org/antlr/v4/tool/templates/codegen/JavaScript/JavaScript.stg#L245>, it is not possible to "finish" the class declaration because another class starts in ruleCtx. Therefore a prototype modification is required. I dont really get how the templates work so if you can give me some guidance there it would be much appreciated :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2787 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJDVAIEBPTE53LHZA3LRNBWYDANCNFSM4LROVWYA>.
|
This PR is a follow up on #2771.
The scope of this PR is to refactor the root js module declarations to:
Implementation notes:
call
method on classes