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

Compiler: Parse infix bitwise operators #297

Closed
ospencer opened this issue Sep 10, 2020 · 12 comments
Closed

Compiler: Parse infix bitwise operators #297

ospencer opened this issue Sep 10, 2020 · 12 comments

Comments

@ospencer
Copy link
Member

Even if they aren't defined yet, we should still parse &, |, ^ (tbd), <<, >>, and >>> so they can be used.

@bmakuh
Copy link
Contributor

bmakuh commented Oct 21, 2020

@ospencer you cool if I take this one?

@bmakuh
Copy link
Contributor

bmakuh commented Oct 21, 2020

Also, what's the tbd on ^?

@ospencer
Copy link
Member Author

@bmakuh Absolutely!

@ospencer
Copy link
Member Author

The tbd on ^ is that we currently use it as the unboxing operator. We have let mut now, so it's a little less necessary that we have syntax for that operator.

Now that I think about it though, we can totally unambiguously parse when it's an infix operator versus when it's a prefix operator.

@ospencer
Copy link
Member Author

If you feel like giving that a shot, definitely give it a go. It may be a little annoying depending on your experience with parser generators (and more specifically dypgen), but we could also pair on it if it gives you a headache!

@ospencer
Copy link
Member Author

Here's where we keep all of the operator precedences: https://github.com/grain-lang/grain/blob/master/docs/contributor/operator_precedence.md

@bmakuh
Copy link
Contributor

bmakuh commented Oct 27, 2020

@ospencer sorry just finally getting around to this. For these operators, is this what you were intending?

sigil operator
& AND
| OR
^ XOR
<< left shift
>> arithmetic right shift
>>> logical right shift

@bmakuh
Copy link
Contributor

bmakuh commented Oct 27, 2020

Also, do we want a NOT operator like ~?

@ospencer
Copy link
Member Author

Yup, >> is the arithmetic (signed) right shift operator, and >>> is the logical (unsigned) right shift operator.

And yeah, we don't want ~ right now since we might be using ~ for something else 🙂

@bmakuh
Copy link
Contributor

bmakuh commented Oct 27, 2020

Ok, thanks. And is there any danger of ambiguity between an infix bitwise pipe operator and other uses of the pipe? I guess we're not using it for match anymore, but it came to mind after you mentioned the unboxing operator

@ospencer
Copy link
Member Author

There shouldn't be! It's only used for || now (and pipeline in the future).

@phated
Copy link
Member

phated commented Dec 16, 2020

This was completed by #425 🎉

@phated phated closed this as completed Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants