Skip to content

Conversation

@walker84837
Copy link
Collaborator

This PR implements if-else control flow for:

  • statements (if (...) { ... } else { ... })
  • expressions (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.

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
@walker84837 walker84837 self-assigned this Dec 21, 2025
@walker84837 walker84837 added the enhancement New feature or request label Dec 21, 2025
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?
@walker84837 walker84837 marked this pull request as ready for review December 22, 2025 05:51
@walker84837 walker84837 merged commit 6de6c06 into main Dec 22, 2025
3 checks passed
@walker84837 walker84837 deleted the if-statements branch December 22, 2025 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants