Use canonical pyparsing names - #191
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s interface parser and its callers to pyparsing’s canonical (PEP 8–style) APIs, including an intentional breaking rename of Module.parseString to Module.parse_string. It updates the Python/MATLAB wrapper entrypoints and parser-related tests to match the new API surface.
Changes:
- Replace deprecated pyparsing camelCase aliases with canonical PEP 8 names across the interface parser (e.g.,
set_parse_action,as_list,nested_expr,string_end). - Rename the project parser entrypoint from
Module.parseStringtoModule.parse_string(no compatibility alias), and update wrappers accordingly. - Update parser tests to use
.parse_string(...)consistently.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_template_instantiator.py | Updates parser rule invocations to .parse_string(...) for template instantiation tests. |
| tests/test_parser_diagnostics.py | Updates diagnostics tests to call Module.parse_string(...). |
| tests/test_interface_parser.py | Updates extensive parser unit tests to use .parse_string(...) consistently. |
| gtwrap/pybind_wrapper.py | Updates pybind wrapper to call parser.Module.parse_string(...). |
| gtwrap/matlab_wrapper/wrapper.py | Updates MATLAB wrapper to call parser.Module.parse_string(...). |
| gtwrap/interface_parser/variable.py | Switches pyparsing parse-action hookup to set_parse_action. |
| gtwrap/interface_parser/type.py | Replaces deprecated pyparsing helpers and methods (e.g., DelimitedList, as_list, set_parse_action). |
| gtwrap/interface_parser/tokens.py | Migrates token helpers to canonical pyparsing names (e.g., nested_expr, original_text_for). |
| gtwrap/interface_parser/template.py | Updates template grammar to use canonical pyparsing names (DelimitedList, set_parse_action, as_list). |
| gtwrap/interface_parser/namespace.py | Updates namespace grammar and parse-result list conversion to canonical names. |
| gtwrap/interface_parser/module.py | Updates module grammar and exposes parse_string as the new parser entrypoint. |
| gtwrap/interface_parser/function.py | Updates function grammar to canonical pyparsing names (DelimitedList, set_parse_action, as_list). |
| gtwrap/interface_parser/enum.py | Updates enum grammar to DelimitedList and set_parse_action. |
| gtwrap/interface_parser/declaration.py | Updates declaration parse actions to set_parse_action. |
| gtwrap/interface_parser/classes.py | Updates class/method grammars to use set_parse_action and as_list. |
| gtwrap/interface_parser/init.py | Switches to ParserElement.enable_packrat() canonical name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Summary
Module.parseStringtoModule.parse_stringwithout a compatibility aliasWhy
Pyparsing 3 recommends its PEP 8 API. The older camelCase spellings are retained only as backward-compatible aliases and can trigger misleading review feedback or eventually be removed. This change uses the canonical API throughout the project while leaving the accepted
.igrammar unchanged.Impact
Callers of the project parser must now use
Module.parse_string. This is an intentional breaking rename;Module.parseStringis not retained.DelimitedListremains PascalCase because it is pyparsing's canonical class name.Validation
conda run -n py312 python -m pytest tests/test_interface_parser.py tests/test_parser_diagnostics.py tests/test_template_instantiator.py— 73 passedconda run -n py312 python -m pytest tests— 110 passedgit diff --checkpy312