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

implement exponentiation operator #89

Closed
arbroween opened this issue Aug 21, 2019 · 5 comments · Fixed by #130
Closed

implement exponentiation operator #89

arbroween opened this issue Aug 21, 2019 · 5 comments · Fixed by #130
Assignees
Labels
good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com

Comments

@arbroween
Copy link
Contributor

The javascript built-in exponentiation operator (**) is missing in the implementation of the lexer. It is a shorthand for Math.pow() built-in.

It should probably be added to the lexer in this method, somewhere in the big match statement https://github.com/jasonwilliams/boa/blob/master/src/lib/syntax/lexer.rs#L207-L533

The operator's syntax and semantics is defined in this section here https://tc39.es/ecma262/#sec-exp-operator in the spec and does the same thing at runtime than Math.pow(), which is already implemented here https://github.com/jasonwilliams/boa/blob/master/src/lib/js/math.rs#L140-L148.

@arbroween
Copy link
Contributor Author

This issue could maybe also be labelled as good first issue

@jasonwilliams jasonwilliams added the good first issue Good for newcomers label Aug 21, 2019
@cpyle0819
Copy link

Re: 'somewhere in the big match statement'. There's already a * operator, so ** should probably be nested within that similar to \\.

The * match is here: https://github.com/jasonwilliams/boa/blob/master/src/lib/syntax/lexer.rs#L479

@cpyle0819
Copy link

Now that I look at it, this looks done.

@jasonwilliams jasonwilliams added the Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com label Sep 3, 2019
@oll3
Copy link
Contributor

oll3 commented Sep 8, 2019

The ** should also be added as an assign op (**=)

@simonbrahan
Copy link
Contributor

Mind if I take a look at this one?

jasonwilliams pushed a commit that referenced this issue Oct 7, 2019
* Exponentiation (**) now works.

Added missing NumOp type, token match, and calculation.

* Assignment exponentiation (**=) now works.

Added missing AssignOp type, token match, and calculation.

This fixes #89.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants