Skip to content

Commit

Permalink
fixed unary minus vs exp precedence, see #41
Browse files Browse the repository at this point in the history
  • Loading branch information
cshaa committed Jun 23, 2021
1 parent e788b57 commit 6e168bf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
8 changes: 4 additions & 4 deletions dist/browser/filtrex.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ var filtrex = (function (exports) {
8: [2, 2],
9: [2, 2],
10: [2, 2],
11: [2, 2],
11: [1, 17],
12: [2, 2],
13: [2, 2],
14: [2, 2],
Expand All @@ -576,7 +576,7 @@ var filtrex = (function (exports) {
8: [2, 11],
9: [2, 11],
10: [2, 11],
11: [2, 11],
11: [1, 17],
12: [2, 11],
13: [2, 11],
14: [2, 11],
Expand Down Expand Up @@ -788,7 +788,7 @@ var filtrex = (function (exports) {
11: [2, 8],
12: [2, 8],
13: [2, 8],
14: [1, 21],
14: [2, 8],
16: [2, 8],
17: [2, 8],
18: [2, 8],
Expand Down Expand Up @@ -1052,7 +1052,7 @@ var filtrex = (function (exports) {
8: [2, 14],
9: [2, 14],
10: [2, 14],
11: [2, 14],
11: [1, 17],
12: [2, 14],
13: [2, 14],
14: [2, 14],
Expand Down
2 changes: 1 addition & 1 deletion dist/browser/filtrex.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/cjs/filtrex.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ var _parser = (function() {
8: [2, 2],
9: [2, 2],
10: [2, 2],
11: [2, 2],
11: [1, 17],
12: [2, 2],
13: [2, 2],
14: [2, 2],
Expand All @@ -577,7 +577,7 @@ var _parser = (function() {
8: [2, 11],
9: [2, 11],
10: [2, 11],
11: [2, 11],
11: [1, 17],
12: [2, 11],
13: [2, 11],
14: [2, 11],
Expand Down Expand Up @@ -789,7 +789,7 @@ var _parser = (function() {
11: [2, 8],
12: [2, 8],
13: [2, 8],
14: [1, 21],
14: [2, 8],
16: [2, 8],
17: [2, 8],
18: [2, 8],
Expand Down Expand Up @@ -1053,7 +1053,7 @@ var _parser = (function() {
8: [2, 14],
9: [2, 14],
10: [2, 14],
11: [2, 14],
11: [1, 17],
12: [2, 14],
13: [2, 14],
14: [2, 14],
Expand Down
3 changes: 1 addition & 2 deletions dist/esm/generateParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ const grammar = {
['left', 'CHAINEDREL'],
['left', '+', '-'],
['left', '*', '/', '%'],
['left', 'not', 'UMINUS'],
['left', '^'],
['left', 'not'],
['left', 'UMINUS'],
['left', 'of'],
],
// Grammar
Expand Down
8 changes: 4 additions & 4 deletions dist/esm/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ var _parser = (function() {
8: [2, 2],
9: [2, 2],
10: [2, 2],
11: [2, 2],
11: [1, 17],
12: [2, 2],
13: [2, 2],
14: [2, 2],
Expand All @@ -574,7 +574,7 @@ var _parser = (function() {
8: [2, 11],
9: [2, 11],
10: [2, 11],
11: [2, 11],
11: [1, 17],
12: [2, 11],
13: [2, 11],
14: [2, 11],
Expand Down Expand Up @@ -786,7 +786,7 @@ var _parser = (function() {
11: [2, 8],
12: [2, 8],
13: [2, 8],
14: [1, 21],
14: [2, 8],
16: [2, 8],
17: [2, 8],
18: [2, 8],
Expand Down Expand Up @@ -1050,7 +1050,7 @@ var _parser = (function() {
8: [2, 14],
9: [2, 14],
10: [2, 14],
11: [2, 14],
11: [1, 17],
12: [2, 14],
13: [2, 14],
14: [2, 14],
Expand Down
3 changes: 1 addition & 2 deletions src/generateParser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ const grammar = {
['left', 'CHAINEDREL'],
['left', '+', '-'],
['left', '*', '/', '%'],
['left', 'not', 'UMINUS'],
['left', '^'],
['left', 'not'],
['left', 'UMINUS'],
['left', 'of'],
],
// Grammar
Expand Down
5 changes: 5 additions & 0 deletions test/arithmetics.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ describe('Arithmetics', () => {
expect( eval('-0.1 % 5') ).equals(4.9)
})


it('exponentiation has precedence over unary minus', () => {
expect( eval('-x^2', {x:2}) ).equals(-4)
})

});

0 comments on commit 6e168bf

Please sign in to comment.