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

Fixed operator precedence #387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/parser/Parser/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ expression = buildExpressionParser opTable highOrderExpr
where
opTable = [
[arrayAccess],
[textualPrefix "not" Identifiers.NOT],
[textualOperator "and" Identifiers.AND,
textualOperator "or" Identifiers.OR],
[prefix "-" NEG],
[op "*" TIMES, op "/" DIV, op "%" MOD],
[op "+" PLUS, op "-" MINUS],
[op "<" Identifiers.LT, op ">" Identifiers.GT,
op "<=" Identifiers.LTE, op ">=" Identifiers.GTE,
op "==" Identifiers.EQ, op "!=" NEQ],
[textualPrefix "not" Identifiers.NOT],
[textualOperator "and" Identifiers.AND,
textualOperator "or" Identifiers.OR],
[messageSend],
[partyLiftf, partyLiftv, partyEach],
[typedExpression],
Expand Down
9 changes: 9 additions & 0 deletions src/tests/encore/basic/operator_precedence.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Main

def main() : void {
print((123 == 100+23 and 789 <= 888) and ((123 == (100+23)) and (789 <= 888)));
print((1+1 == 2 == true or false) and (((1+1 == 2) == true) or false)) ;
let a = Just 45;
let b = Nothing : Maybe int;
print((a != Nothing and b == Nothing) and ((a != Nothing) and (b == Nothing)))
}
3 changes: 3 additions & 0 deletions src/tests/encore/basic/operator_precedence.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
true
true
true