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

Expressions overhaul #27

Merged
merged 4 commits into from
May 3, 2022
Merged

Expressions overhaul #27

merged 4 commits into from
May 3, 2022

Conversation

James-Livesey
Copy link
Member

This PR fixes the usage of both logical operators and comparators by merging them into the main expression parsing and evaluation system, instead of treating them as a special type of expression. That way, for example, 5 = 5 will evaluate to 1, and 4 = 5 will evaluate to 0.

This opens up the possibilities for new syntax while preserving the behaviour of old programs:

  • if booleanCondition = 1 can now be rewritten as if booleanCondition
  • Boolean logic expressions can be stored in variables and printed
  • true and false constants are now provided, set to 1 and 0 respectively

This means that the result of logical expressions can be stored in
variables, in addition to the fact that those variables can then be
checked in an `if` statement without having to check if equal to 1.
@James-Livesey James-Livesey added the bug Something isn't working label May 3, 2022
@James-Livesey James-Livesey merged commit b0c7de6 into main May 3, 2022
@James-Livesey James-Livesey deleted the expressions-overhaul branch May 3, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant