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
Javascript: migrate prototypical ATN objects to ES6 #2771
Conversation
fix: put the documentation on the method, not on the import fix: move Token import to the top
use module.exports use const/let use jsdoc
fix: dont wrap class in an object refactored imports accordingly
use module.exports use jsdoc
use jsdoc use module.exports
fix: dont wrap the class in an object for export
use const for better scoping fix: dont wrap class in object for export
use const for better scoping fix: dont wrap class in object for export
use const/let for better scoping fix: dont wrap class in object for export
use const/let for better scoping use object destructuring fix: dont wrap class in object for export
use const/let for better scoping use object destructuring fix: dont wrap class in object for export
use const/let for better scoping use object destructuring use jsdoc
use const for better scoping
Hi, thanks for this re "NOTE: I also renamed this "constructor" to be the equals method as it made no sense to have two constructors and for consistency with the SemanticContext.java implementation" Cheers |
@ericvergnaud it seems that github doesnt show the file due to the file being "collapsed" i.e diff too big. Anyway, here is the actual diff. Specifically this below: OR.prototype = Object.create(SemanticContext.prototype);
OR.prototype.constructor = OR;
OR.prototype.constructor = function(other) {
if (this === other) {
return true;
} else if (!(other instanceof OR)) {
return false;
} else {
return this.opnds === other.opnds; As you can see the code declares the constructor of |
it does look like a bug, but then I wonder how the whole thing works... |
maybe we're lacking some tests for semantic predicates |
a simple const foo = new OR("a", "b")
console.log(foo) at the end of the |
@parrt blessed |
@carocad if not already done, would you be able to provide a doc for using this ES6 version locally? |
Not sure what you mean. Locally it is simply using node.js so a standard That is also what the test suite does. Generates the code and copies the js runtime locally so that it is available.
mmmm 🤔 . I tried I could do an extra guide on how to use it but right now I don't know exactly what to put there as it is simply "require it as you would any other node.js library" 🤷♂️ |
I suspect the issue I encountered related to using pre ES6 generated parser and lexer with latest ES6 runtime in node
I’ll double check, and if the case, we'll need to document that to limit support
… Le 14 juil. 2020 à 03:16, Camilo Roca ***@***.***> a écrit :
would you be able to provide a doc for using this ES6 version locally?
Not sure what you mean. Locally it is simply using node.js so a standard const antlr4 = require('./src/antlr4') would do (assuming that you are in the js runtime dir).
That is also what the test suite does. Generates the code and copies the js runtime locally so that it is available.
I've tried npm link, which ends up badly (ES2015 functions inheriting from ES6 classes...)
mmmm 🤔 . I tried npm link as per the official documentation <https://docs.npmjs.com/cli/link> and it worked as expected. I was able to import the library with const antlr4 = require('antlr4'). Nodejs displays the antlr4 object as containing functions however I think that is normal; as classes are just sugared functions.
I could do an extra guide on how to use it but right now I don't know exactly what to put there as it is simply "require it as you would any other node.js library" 🤷♂️
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2771 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAZNQJABLXDH475CMS3R2N3R3NMR7ANCNFSM4LDZSDOA>.
|
This PR is a follow up on #2749.
The scope of this PR is to refactor the ATN object declarations to:
NOTE: I also renamed this "constructor" to be the
equals
method as it made no sense to have two constructors and for consistency with theSemanticContext.java
implementation