feat: implement module system foundation (parser + resolver)#2
Draft
feat: implement module system foundation (parser + resolver)#2
Conversation
Co-authored-by: igorgue <7014+igorgue@users.noreply.github.com>
- Add mod_kw token type to TokenType enum - Add mod keyword recognition in getKeywordType (length 3, 'm') - Add mod_decl node type to AST NodeType enum - Add mod_info struct to AST extra union with module_name, file_path, is_main fields - Implement setModInfo helper method for setting module information - Add mod_decl cleanup in deinit for proper memory management - Implement parseModDecl function to parse module declarations - Add module parsing to parseDeclaration dispatch - Create test_module_parsing.zig with basic module parsing tests - Register module parsing tests in build.zig Co-authored-by: igorgue <7014+igorgue@users.noreply.github.com>
- Add tests for dotted import paths (utils.math) - Add tests for aliased imports (import X as Y) - Add tests for selective imports (from X import a, b) - Create simple module system example with utils.sho and main.sho - Add expected output for module example - Create MODULE_STATUS.md to track implementation progress Co-authored-by: igorgue <7014+igorgue@users.noreply.github.com>
…rt detection - Create src/module_resolver.zig with ModuleResolver struct - Implement module name to file path conversion (utils.math → utils/math.sho) - Add search path management for module discovery - Implement circular import detection using DFS algorithm - Add module name extraction from file paths - Create loaded modules cache to avoid redundant parsing - Track import dependency graph for validation - Add comprehensive tests for all resolver functionality - Register module_resolver module in build.zig - Create test_module_resolver.zig with 10+ test cases - Update MODULE_STATUS.md - Phase 2 complete! Co-authored-by: igorgue <7014+igorgue@users.noreply.github.com>
- Create MODULE_IMPLEMENTATION_SUMMARY.md documenting all changes - Detail Phases 1 & 2 implementation (parser + module resolver) - Document design decisions and architecture - List all files changed/added with line counts - Provide usage examples and next steps - Include testing strategy and coverage details - Document compatibility and performance considerations Co-authored-by: igorgue <7014+igorgue@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement module system in Shortcake
feat: implement module system foundation (parser + resolver)
Nov 16, 2025
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.
Implements Phases 1-2 of the Shortcake module system per
docs/MODULES.md: parser extensions and module resolution infrastructure.Parser Extensions
modkeyword: New token type, AST node (mod_decl), and parsing logicmod_infostruct (module_name, file_path, is_main) with proper memory managementutils.math) works with new module systemModule Resolver
New
src/module_resolver.zigprovides:utils.math→utils/math.shoExample Module
Changes
src/parser.zig:parseModDecl(),mod_kwtoken recognitionsrc/ast.zig:mod_declnode type,setModInfo()helpersrc/module_resolver.zig: New (370 lines)test/test_module_parsing.zig: New - parser teststest/test_module_resolver.zig: New - 10+ resolver testsbuild.zig: Module registrationNext: Symbol resolution (import tracking, cross-module references)
Total: ~930 lines (implementation + tests)
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/igorgue/shortcake/git/blobs/b609b3bc9890080ef4b7c1b1932209f194dc061eimport urllib.request
import json
import base64
url = 'REDACTED'
req = urllib.request.Request(url)
req.add_header('Accept', 'application/vnd.github.v3+json')
with urllib.request.urlopen(req) as response:
data = json.loads(response.read())
content = base64.b64decode(data['content']).decode('utf-8')
print(content)` (http block)
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.