Implement if statements#3
Merged
Merged
Conversation
This commit adds if-else control flow for both statements and expressions. As part of this implementation, a pre-existing bug in binary operator parsing was discovered and fixed. The expression parser now correctly handles precedence for equality and comparison operators - Add if‑else statements with blocks - Add if‑else expressions for use in assignments and other expressions - Add a new test case (`if_else`) to verify the functionality - Add BinaryOp to the Expr AST to represent binary operations - Update the expression parser to correctly build a tree for binary expressions - Made operator rules in the pest grammar explicit to improve parsing correctness
This change would take automatically adding the stdbool.h header every time the "false" and "true" literals are used in the Kit source. This, for some reason, works on my Arch Linux install, but doesn't on Ubuntu. Maybe due to incorrect compiler invocation?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements if-else control flow for:
if (...) { ... } else { ... })if ... then ... else ...)I also found and fixed a bug in the way binary operators are parsed. The expression parser now correctly handles precedence for equality and comparison operators.
This PR is useful in this context because it adds a part of the fundamental Kit syntax.