-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for multi-dimensional arrays #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive support for multi-dimensional arrays to both Python and custom grammar syntaxes, replacing the previous X * Type syntax with the new Type[X] format. Key changes include extending the core array infrastructure to handle arbitrary dimensions, updating the grammar parser to support multiple packages per file, and providing comprehensive test coverage for the new functionality.
- Replaces
X * Typearray syntax with modernType[X]bracket notation - Extends
ArraySpecandPackedArrayto support multi-dimensional arrays with arbitrary depth - Updates grammar parser to handle multiple packages in a single file and inline foreign references
Reviewed Changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/test_utils_constant.py | Updates test to handle multiple packages in parse output |
| tests/utils/test_utils_basic.py | Updates imports and type references for scalar refactoring |
| tests/pysyntax/test_struct.py | Updates array syntax from X * Type to Type[X] format |
| tests/pysyntax/test_package.py | Updates array syntax from X * Type to Type[X] format |
| tests/pysyntax/test_array.py | Comprehensive test suite for multi-dimensional array functionality |
| tests/grammar/*.py | Updates all grammar tests to handle multiple packages per file |
| pyproject.toml | Version bump to 3.0.2 |
| packtype/utils/union.py | Updates scalar type references for refactoring |
| packtype/utils/struct.py | Updates scalar type references for refactoring |
| packtype/utils/basic.py | Major refactoring of type handling and addition of scalar utilities |
| packtype/utils/array.py | New utility module for array-related operations |
| packtype/utils/init.py | Exports new array utilities and scalar checking functions |
| packtype/types/scalar.py | Refactors Scalar into ScalarType base with backward compatibility |
| packtype/types/primitive.py | Splits NumericType from NumericPrimitive for better type hierarchy |
| packtype/types/package.py | Updates type filtering and scalar reference handling |
| packtype/types/base.py | Adds __getitem__ method for array syntax and metadata support |
| packtype/types/assembly.py | Updates array range calculation for multi-dimensional support |
| packtype/types/array.py | Complete rewrite to support multi-dimensional arrays |
| packtype/templates/package.sv.mako | Updates SystemVerilog template for new array syntax |
| packtype/start.py | Updates imports and loop handling for multiple packages |
| packtype/registers/registers.py | Updates type references for scalar refactoring |
| packtype/grammar/transformer.py | Major updates to support new array dimensions and foreign references |
| packtype/grammar/packtype.lark | Grammar updates for dimensions, foreign references, and multi-package support |
| packtype/grammar/grammar.py | Parser updates to yield multiple packages and handle foreign references |
| packtype/grammar/declarations.py | New declaration types and dimension handling logic |
| examples/*/registers.py | Updates array syntax from X * Type to Type[X] format |
| examples/arrays/* | New comprehensive example demonstrating multi-dimensional arrays |
| docs/syntax/arrays.md | New documentation for array syntax and usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
X * Typesyntax in favour ofType[X]ArraySpecandPackedArrayto support any number of dimensionsmy_type_t : pkg_a::some_type_t[1][2]works)