Skip to content

Commit

Permalink
Merge pull request #446 from frostburn/js-exponentiation
Browse files Browse the repository at this point in the history
Add ExponentiationExpression rule to javascript.pegjs
  • Loading branch information
hildjj authored Dec 3, 2023
2 parents f323563 + 221aa9e commit 8aa207c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ fpirsch <fpirsch@free.fr> (https://github.com/fpirsch/)
markw65 <mark@replayroutes.com> (https://github.com/markw65/)
Andy (https://github.com/AndrewRayCode)
Kristian Dupont <kristian@kristiandupont.com> (https://github.com/kristiandupont/)
Lumi Pakkanen <lumi.pakkanen@gmail.com> (https://github.com/frostburn/)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Released: TBD

### Minor Changes

- [#446](https://github.com/peggyjs/peggy/pull/446) Add a right-associative `ExponentiationExpression` rule (operator `**`) to `javascript.pegjs` example grammar.
- [#427](https://github.com/peggyjs/peggy/pull/427) Avoid double extraction of
substrings in various MATCH_ bytecodes
- [#425](https://github.com/peggyjs/peggy/pull/425) Add a pass to simplify single-character choices
Expand Down
15 changes: 12 additions & 3 deletions examples/javascript.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,17 @@ UnaryOperator
/ "~"
/ "!"

MultiplicativeExpression
ExponentiationExpression
= head:UnaryExpression
tail:(__ MultiplicativeOperator __ UnaryExpression)*
tail:(__ ExponentiationOperator __ ExponentiationExpression)*
{ return buildBinaryExpression(head, tail); }

ExponentiationOperator
= $("**" !"=")

MultiplicativeExpression
= head:ExponentiationExpression
tail:(__ MultiplicativeOperator __ ExponentiationExpression)*
{ return buildBinaryExpression(head, tail); }

MultiplicativeOperator
Expand Down Expand Up @@ -930,7 +938,8 @@ AssignmentExpressionNoIn
/ ConditionalExpressionNoIn

AssignmentOperator
= "*="
= "**="
/ "*="
/ "/="
/ "%="
/ "+="
Expand Down

0 comments on commit 8aa207c

Please sign in to comment.