-
Notifications
You must be signed in to change notification settings - Fork 48
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
ES Next: Logical assignment operators #168
Comments
Try use option cc / @3cp |
I use Is it supposed to work? I can investigate further if it is, but I have the impression it's not. |
What is the code line you try to parse? It's implemented in Meriyah without any need to enable IGNORE I got confused by my own parser, but I noticed now this is not implemented in Meriyah source! @3cp Will you take a stab at it? |
@KFlash I saw you have a parser of your own. Would you advise using it? |
I think Meriyah is the best choice. I have my own parser yes, but it's part of my non-open source project. I archived my goal and still playing around. You can check out this readme and try out the demo. Meriyah is a simple JS parser that follows ESTree and also used in Prettier. It's an better alternative than for example Acorn due to it's performance. |
Looks like not difficult to implement. Question @KFlash, do we want to shift the numbers below assign operators to make spaces for /* Assign operators */
Assign = 29 | IsAssignOp | IsClassField, // =
ShiftLeftAssign = 30 | IsAssignOp, // <<=
ShiftRightAssign = 31 | IsAssignOp, // >>=
LogicalShiftRightAssign = 32 | IsAssignOp, // >>>=
ExponentiateAssign = 33 | IsAssignOp, // **=
AddAssign = 34 | IsAssignOp, // +=
SubtractAssign = 35 | IsAssignOp, // -=
MultiplyAssign = 36 | IsAssignOp, // *=
DivideAssign = 37 | IsAssignOp | IsExpressionStart, // /=
ModuloAssign = 38 | IsAssignOp, // %=
BitwiseXorAssign = 39 | IsAssignOp, // ^=
BitwiseOrAssign = 40 | IsAssignOp, // |=
BitwiseAndAssign = 41 | IsAssignOp, // &=
// Do we give 42, 43, 44 to ||=, &&=, and ??= ?
// Or use 136, 137, 138 (after the last one JSXText 135)?
/* Unary/binary operators */
TypeofKeyword = 42 | IsUnaryOp | Reserved,
DeleteKeyword = 43 | IsUnaryOp | Reserved,
VoidKeyword = 44 | IsUnaryOp | Reserved,
Negate = 45 | IsUnaryOp, // ! |
The order doesn't matter, but probably easier to understand if grouped together like Do not forget to add The token dispatch code also need a quick update for this to work, but nothing of this is super hard. Maybe 10 min to fix it. |
@KFlash does stage4 mean still need |
It's means it's implemented in all browsers and is now part of the ECMA language, so no! |
Good, I didn't do that. |
This proposal is completed (stage 4) and supported by TS, it's expected to be part of ES2021.
https://github.com/tc39/proposal-logical-assignment
It also works in most browsers today:
https://caniuse.com/mdn-javascript_operators_logical_nullish_assignment
Can you add support for it?
I have code that uses
??=
and it doesn't parse :(The text was updated successfully, but these errors were encountered: