feat: implement increment/decrement operators and semantic mutability validation #256
+452
−12
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 introduces support for standard C-style increment (
++) and decrement (--) operators in both prefix and postfix forms. Additionally, it implements a new semantic verification layer to enforce mutability rules, ensuring that variables are only modified when explicitly declared as mutable.Key Changes
1. AST & Parser Enhancements
IncDecexpression variant andIncDecKind(PreInc, PreDec, PostInc, PostDec) to the AST.parse_unary_expressionto handle prefix operators.parse_expressionwith lookahead logic to identify postfix operators.is_assignablechecks to ensure++/--are only applied to valid targets (variables, array indices, struct fields, and dereferenced pointers).2. New Semantic Verification Module
verificationmodule that performs a full AST traversal before code generation.Mutabilitystatus.let x = 5; x++;will now fail during semantic analysis).3. LLVM Code Generation
load->add/sub->storepattern for all supported types:generate_address_irto robustly handle grouped expressions and complex dereferences.4. Testing & Documentation
test72.waveandtest73.wave.Example Usage
Benefits