Skip to content

Added loop control heel and stay and updated the relevant docs#21

Open
Rayaan-Raza wants to merge 1 commit into
Pallavrai:mainfrom
Rayaan-Raza:loop-control
Open

Added loop control heel and stay and updated the relevant docs#21
Rayaan-Raza wants to merge 1 commit into
Pallavrai:mainfrom
Rayaan-Raza:loop-control

Conversation

@Rayaan-Raza

Copy link
Copy Markdown

No description provided.

@Rayaan-Raza

Copy link
Copy Markdown
Author

Works seamlessly with wagtail loops

Supports nested loops

Proper error handling when used outside loops

Fully covered by new test cases

Updated docs and examples so users can get started right away

🔧 Under the Hood

Added a loopcontrol.py module with a handler and error class

Integrated heel/stay parsing in SyntaxAnalyser.py

Updated main.py with execution logic and better loop context handling

Improved tokenizer (Tokenizer.py) to properly handle comments

📚 Docs & Examples

Updated features.md and usage.md with examples

Added sample .doggy programs showing basic and advanced use of heel and stay

🧪 Testing

New test suite (tests/test_loop_control.py) with 8 cases

Covers basics, nested loops, invalid usage, and conditionals

✅ All tests passing

💡 Example

Break (heel):

wagtail i < 5 {
bark i;
i = i + 1;
sniff i == 3 {
heel;
}
}

Output: 0, 1, 2

Continue (stay):

wagtail i < 5 {
i = i + 1;
sniff i % 2 == 0 {
stay;
}
bark i;
}

Output: 1, 3, 5

🐛 Fixes Along the Way

Replaced recursive loop execution with a safer iterative approach (fixes infinite loops)

Fixed tokenizer so comments (#) are no longer parsed as code

Improved loop context + flag management

✅ Checklist

Loop control implemented

Parser + interpreter updated

Tests written & passing

Docs & examples added

No breaking changes

@Pallavrai

Copy link
Copy Markdown
Owner

Hey @Rayaan-Raza , just saw your implementation please try to understand code first, don't use AI tools blindly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants