Skip to content

feat(expression,lua): add legacy List/Dict AST compatibility for protocol DSL - #51

Merged
cherninkiy merged 2 commits into
mainfrom
dev
Apr 19, 2026
Merged

feat(expression,lua): add legacy List/Dict AST compatibility for protocol DSL#51
cherninkiy merged 2 commits into
mainfrom
dev

Conversation

@cherninkiy

Copy link
Copy Markdown
Collaborator

What

  • Added legacy AST nodes List and Dict to improve compatibility with external AST producers while keeping the parser surface strict.

Extended expression runtime support:

  • evaluator now handles legacy List and Dict nodes.
  • validator now traverses legacy List and Dict nodes in name collection and comprehension checks.

Extended Lua Wireshark generation:

  • Lua expression compiler now supports legacy List and Dict nodes.
  • Name reference collection for dependency ordering now supports legacy List and Dict nodes.

Added regression tests:

  • evaluator coverage for legacy List and Dict evaluation.
  • Lua compiler coverage for legacy List and Dict to 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

  • No expansion of parser grammar.
  • No runtime function-call execution path introduced.
  • Compatibility-only extension for legacy container AST nodes.

Validation

Ran:

pytest -q test_expression_evaluator.py test_python_lua_generators.py

Result: 56 passed

Context

Selected domain-safe portability from https://github.com/protocollab-co/protocollab-octapi

- 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=...) and Dict(pairs=...) and export them from protocollab.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
@cherninkiy
cherninkiy merged commit e939548 into main Apr 19, 2026
6 checks passed
@cherninkiy
cherninkiy deleted the dev branch April 19, 2026 20:46
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