Skip to content

Conversation

@Intuity
Copy link
Owner

@Intuity Intuity commented Jul 4, 2025

This PR is a significant extension to Packtype, adding an entirely custom grammar for declaring packages, constants, enums, structs, and unions.

  • Adds a custom EBNF grammar using Lark;
  • Adds a transformer to map Lark parser output onto Packtype's internal types;
  • Adds unit tests to exercise custom grammar and error cases;
  • Adds .pt variants to all compatible examples;
  • Adds Packtype grammar definitions to each page of documentation;
  • Bumps version to 3.0.0 (major change);
  • Restructures CLI commands to allow multiple .pt files to be specified;
  • Extends utils to wrap many of the _pt_ methods.

@Intuity Intuity changed the title Adding a custom .pt grammar as an alternative to dataclass style declarations [WIP] Adding a custom .pt grammar as an alternative to dataclass style declarations Jul 4, 2025
@Intuity Intuity marked this pull request as draft July 4, 2025 09:34
@Intuity Intuity requested a review from Copilot July 4, 2025 14:03
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

Adds support for a custom .pt grammar alongside dataclass-style declarations for Packtype, updates the VS Code extension metadata, enhances the CLI to accept multiple specification files and name‐filtering options, and adjusts tests and docs to reflect the new grammar.

  • Introduced Lark grammar and VS Code syntax highlighting for .pt files
  • Enhanced CLI (__main__.py) to load multiple spec files and apply naming filters
  • Updated tests, examples, and documentation to cover and demonstrate the new .pt syntax
Comments suppressed due to low confidence (3)

docs/syntax/union.md:94

  • The description mentions "struct" but this is in the union documentation. Change to "bit width of the union."
 * `<UNION>._pt_width` - property that returns the bit width of the struct;

vscode/packtype/language-configuration.json:3

  • JSON does not support comments; these // lines will break parsing. Remove or convert them to valid JSON keys.
        // symbol used for single line comment. Remove this entry if your language does not support line comments

tests/integration/test_sv.py:23

  • The test moved the file‐path argument after the code subcommand, changing the CLI invocation order and likely breaking the test. The .pt file path should appear immediately after the --debug flag.
            (resources / "test_pkg.py").as_posix(),

@Intuity Intuity changed the title [WIP] Adding a custom .pt grammar as an alternative to dataclass style declarations Adding a custom .pt grammar as an alternative to dataclass style declarations Jul 4, 2025
@Intuity Intuity marked this pull request as ready for review July 4, 2025 14:17
@Intuity Intuity merged commit 4b67633 into main Jul 13, 2025
6 checks passed
@Intuity Intuity deleted the intuity/lark branch July 13, 2025 13:04
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