diff --git a/AUTHORS b/AUTHORS index f0536d4d..6e314879 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,3 +34,4 @@ fpirsch (https://github.com/fpirsch/) markw65 (https://github.com/markw65/) Andy (https://github.com/AndrewRayCode) Kristian Dupont (https://github.com/kristiandupont/) +Lumi Pakkanen (https://github.com/frostburn/) diff --git a/CHANGELOG.md b/CHANGELOG.md index 758db00e..8e1f9763 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/examples/javascript.pegjs b/examples/javascript.pegjs index 4b4c4936..06844474 100644 --- a/examples/javascript.pegjs +++ b/examples/javascript.pegjs @@ -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 @@ -930,7 +938,8 @@ AssignmentExpressionNoIn / ConditionalExpressionNoIn AssignmentOperator - = "*=" + = "**=" + / "*=" / "/=" / "%=" / "+="