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

Cannot define some custom operators #23

Closed
kmarekspartz opened this issue Feb 16, 2014 · 2 comments
Closed

Cannot define some custom operators #23

kmarekspartz opened this issue Feb 16, 2014 · 2 comments

Comments

@kmarekspartz
Copy link
Contributor

I cannot create custom operators for | and &:

class Set {
  // ...
  | that {
    // Union
    return new Set  // ...
  }
}

I may add tests for each of the possible custom operators.

@kmarekspartz
Copy link
Contributor Author

Oh, the error message:

[example/set.wren line 3] Error on '|': Expect method definition.
[example/set.wren line 3] Error on 'that': Expect end of file.

@munificent
Copy link
Member

Ah, yes. The bitwise operators haven't been implemented yet. :)

If you feel like hacking some C code, this might be an easy bug to get your feet wet. & and | are already being lexed, so all you need to do is add grammar rules for them in the rule table in wren_compiler.c:2004. They'll just use INFIX_OPERATOR like the other normal infix operators do, with PREC_BITWISE.

We should implement primitive & and | operators on numbers and bools too, but that can be done separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants