Skip to content

Conversation

@Intuity
Copy link
Owner

@Intuity Intuity commented Sep 3, 2025

This PR adds support for attaching instances of defined types to packages as typed constants:

  • Extends the custom grammar to allow instances of types to be declared;
  • Adds _pt_attach_instance method to Package, which can be used with the Python syntax to achieve the same thing;
  • Extends unit tests to cover the new features;
  • Extends package template to render instances.

@Intuity Intuity requested a review from Copilot September 3, 2025 09:49
Copy link

Copilot AI left a 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 instances (typed constants) to the packtype system, allowing users to declare and use structured constant values within packages.

  • Adds new DeclInstance declaration type and _pt_attach_instance method to handle typed constants
  • Extends grammar to support both simple enum instances and complex struct instances with field assignments
  • Updates SystemVerilog template generation to properly render instance constants

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/grammar/test_instances.py New comprehensive test suite covering enum and struct instance parsing
packtype/grammar/declarations.py Adds DeclInstance, FieldAssignment, and FieldAssignments classes
packtype/grammar/transformer.py Updates decl_alias method to handle instance declarations alongside aliases
packtype/grammar/packtype.lark Extends grammar to support field assignments and instance syntax
packtype/grammar/grammar.py Integrates instance processing into the main parsing pipeline
packtype/types/package.py Adds _pt_attach_instance method and _pt_instances property
packtype/templates/package.sv.mako Updates SystemVerilog template to render instance constants
packtype/utils/basic.py Adds get_package utility and updates get_name for scalar types
packtype/common/expression.py Adds support for foreign reference evaluation in expressions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Intuity Intuity merged commit a925f16 into main Sep 3, 2025
6 checks passed
@Intuity Intuity deleted the intuity/typed-consts branch September 3, 2025 10:07
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