forked from grain-lang/grain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grainfmt): Remove extraneous parens around infix function applica…
…tion (grain-lang#902) Check operator precedence when adding parens for infix operations and remove redundant parens
- Loading branch information
1 parent
5788126
commit 5c1906a
Showing
10 changed files
with
191 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
let x = y => y + 0 | ||
|
||
x(3) + 4 | ||
|
||
let a = true | ||
let b = false | ||
let c = false | ||
|
||
if ((a && b) || c) { | ||
print("who knows") | ||
} | ||
|
||
if (a && (b || c)) { | ||
print("who knows") | ||
} | ||
|
||
3 + (4 * 5) | ||
|
||
(3 + 4) * 5 | ||
|
||
3 - 4 + 5 | ||
3 - (4 + 5) | ||
|
||
"a" ++ "b" ++ "c" | ||
|
||
|
||
|
||
let zz = (3 - 4) + (5 - 6); | ||
let zz2 = (3 - 4) * (5 - 6); | ||
let zz3 = (3 * 4) * (5 - 6); | ||
|
||
print (x(3)+x(4)) | ||
print (x(3)-x(4)+x(5)) | ||
print (x(3)-(x(4)+x(5))) | ||
print ((x(3)-x(4))+x(5)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ if (a && b) { | |
print("true") | ||
} | ||
|
||
if ((a && b) || c) { | ||
if (a && (b || c)) { | ||
print("who knows") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let x = y => y + 0 | ||
|
||
x(3) + 4 | ||
|
||
let a = true | ||
let b = false | ||
let c = false | ||
|
||
if (a && b || c) { | ||
print("who knows") | ||
} | ||
|
||
if (a && (b || c)) { | ||
print("who knows") | ||
} | ||
|
||
3 + 4 * 5 | ||
|
||
(3 + 4) * 5 | ||
|
||
3 - 4 + 5 | ||
3 - (4 + 5) | ||
|
||
"a" ++ "b" ++ "c" | ||
|
||
let zz = 3 - 4 + (5 - 6) | ||
let zz2 = (3 - 4) * (5 - 6) | ||
let zz3 = 3 * 4 * (5 - 6) | ||
|
||
print(x(3) + x(4)) | ||
print(x(3) - x(4) + x(5)) | ||
print(x(3) - (x(4) + x(5))) | ||
print(x(3) - x(4) + x(5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters