feat(expression,lua): add legacy List/Dict AST compatibility for protocol DSL - #51
Merged
Conversation
- add legacy List/Dict AST nodes and keep parser surface strict - support legacy nodes in evaluator, validator, and Lua Wireshark generation - add regression tests for legacy AST -> Lua and evaluator compatibility - context: selected domain-safe portability from github.com/protocollab-co/protocollab-octapi
Contributor
There was a problem hiding this comment.
Pull request overview
Adds backwards-compatible support for legacy expression AST container nodes (List / Dict) across the expression runtime (evaluation + validation) and Lua (Wireshark) generation, enabling interoperability with external AST producers while keeping the expression parser unchanged.
Changes:
- Introduce legacy AST nodes
List(elements=...)andDict(pairs=...)and export them fromprotocollab.expression. - Extend evaluator/validator and Lua expression compilation + name reference collection to handle the legacy nodes.
- Add regression tests covering legacy-node evaluation and Lua compilation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/protocollab/expression/ast_nodes.py | Adds legacy List/Dict AST node dataclasses and includes them in ASTNode. |
| src/protocollab/expression/init.py | Exposes List/Dict in the public expression module API. |
| src/protocollab/expression/evaluator.py | Evaluates legacy List/Dict nodes equivalently to ListLiteral/DictLiteral. |
| src/protocollab/expression/validator.py | Traverses legacy List/Dict nodes in name collection and comprehension variable validation. |
| src/protocollab/generators/lua_generator.py | Compiles legacy List/Dict nodes to Lua tables and includes them in dependency name reference collection. |
| src/protocollab/tests/expression/test_expression_evaluator.py | Adds evaluation regression tests for legacy list/dict nodes. |
| src/protocollab/tests/generators/test_python_lua_generators.py | Adds Lua compilation regression tests for legacy list/dict nodes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- reformat test_python_lua_generators.py to satisfy black --check - keep behavior unchanged; formatting-only update
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.
What
ListandDictto improve compatibility with external AST producers while keeping the parser surface strict.Extended expression runtime support:
ListandDictnodes.ListandDictnodes in name collection and comprehension checks.Extended Lua Wireshark generation:
ListandDictnodes.ListandDictnodes.Added regression tests:
ListandDictevaluation.ListandDictto Lua table output.Why
This improves domain-focused interoperability for network protocol and binary format workflows where expression ASTs may be produced by adjacent tooling, while preserving current parser security boundaries (no new callable syntax exposed to user expressions).
Scope and safety
Validation
Ran:
Result: 56 passed
Context
Selected domain-safe portability from https://github.com/protocollab-co/protocollab-octapi