Implement function parameters, logical operators (&&, ||), and loops (while, for)#9
Merged
vmillet-dev merged 10 commits intomainfrom Jul 27, 2025
Merged
Conversation
…(while, for) - Add While, For, Break, Continue AST nodes to support loop constructs - Implement function parameter parsing in parser with Parameter struct - Add logical operator precedence handling for && and || operators - Implement loop statement parsing for while, for, break, continue - Add IR generation for loop control flow with proper label management - Implement short-circuit evaluation for logical operators in IR - Add comprehensive unit and integration tests for all new features - Support nested loops and complex logical expressions - All tests pass (58 unit + 26 integration tests) Co-Authored-By: Valentin Millet <valentin.millet39@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
472e74e to
fbdea63
Compare
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.
Implement function parameters, logical operators (&&, ||), and loops (while, for)
Summary
This PR implements three major language features for the Mini-C compiler's IR compilation pipeline:
int add(int a, int b))&&and||with proper short-circuit evaluationwhileandforloops withbreakandcontinuesupportThe implementation spans the entire compilation pipeline from lexer tokens to IR generation, focusing exclusively on the IR compilation mode (
cargo run -- --ir) as requested.Review & Testing Checklist for Human
false && expensive_call()doesn't execute the right side, andtrue || expensive_call()doesn't execute the right side(a && b) || (c && d)Diagram
%%{ init : { "theme" : "default" }}%% graph TD subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end TokenTypes["src/lexer/token.rs<br/>TokenType definitions"]:::context AST["src/parser/ast.rs<br/>AST node definitions"]:::major-edit Parser["src/parser/parser.rs<br/>Parsing logic + tests"]:::major-edit Semantic["src/semantic/lifetime_simple.rs<br/>Semantic analysis"]:::minor-edit IRGen["src/ir/generator.rs<br/>IR generation"]:::major-edit IRCodegen["src/codegen/ir_codegen.rs<br/>IR to assembly"]:::context IntegrationTests["tests/integration_tests.rs<br/>Integration tests"]:::major-edit TokenTypes --> Parser AST --> Parser Parser --> Semantic Parser --> IRGen IRGen --> IRCodegen IRGen --> IntegrationTests classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes