-
Notifications
You must be signed in to change notification settings - Fork 26.5k
feat(parser): support === and !== operators #1500
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
feat(parser): support === and !== operators #1500
Conversation
@vicb I was a bit surprised to see that |
Dart doesn't support |
Oh, good - we should be fine then! |
@@ -304,7 +304,7 @@ class _Scanner { | |||
assert(this.peek == StringWrapper.charCodeAt(one, 0)); | |||
this.advance(); | |||
var str:string = one; | |||
if (this.peek == code) { | |||
while (this.peek == code) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this only work because by luck '=' = '=' ? (ie should we add three ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicb not sure I got you here. We are getting a right token out of lexer: pkozlowski-opensource@8d58892#diff-97c47bfad039c045846c9d65a42b72f9R161
I'm pushing even more tests :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at the details but you do str += two
multiple times, is that right or does this happen to work because the tokens end with a doubled symbol (2*=
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what if ======================
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works since both !==
and ===
and with the same two
(=
) token. And at the end we do verify that what got built is a real operator, see: pkozlowski-opensource@9e5c882#diff-64a5b021a00571a4aa77bbc3c3c08057R311
So I guess there is some kind of back-tracking mechanism (?). But even if there would, I guess it would be less efficient than just introducing 3rd arg. Let me change the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicb actually I think we are fine with the current impl. I was trying to break it with many use cases but can't. For example, if you do ======================
you will just get an invalid operator ======================
with the current impl. If we are more explicit we would get several tokens with the ===
which would be an invalid expression anyway. So we would just do more work for nothing....
8d58892
to
9e5c882
Compare
@vicb I've pushed an update with more tests. I'm still not sure about your comment. Can you think of a test that would show it breaking? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #1496