Align transformer spec, add tests, update docs#254
Conversation
Aligned the transformer declaration grammar to require a colon and at least one output identifier, matching parser implementation. Updated documentation to reflect that transformer names and output names accept any non-keyword identifier token, and recovery is line-oriented. Added tests to verify that transformer declarations without a colon fail as expected. Marked docs/roadmap item 2.6.5 as completed. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Align transformer declaration grammar with documented syntaxOverviewThis PR (closes Key changes
Issues / follow-ups
Impact
WalkthroughUpdate transformer-declaration docs and tests: grammar requires Changes
Poem
🚥 Pre-merge checks | ✅ 8 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (8 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsTimed out fetching pipeline failures after 30000ms Comment |
Reviewer's GuideAligns the documented transformer declaration grammar with the implemented parser behavior (colon + required outputs, generic identifiers, line-based recovery) and adds a regression test ensuring declarations missing the colon fail to parse and produce no transformers. Sequence diagram for transformer declaration parsing and line-oriented recoverysequenceDiagram
participant SourceFile
participant TransformerScanner
participant ChumskyTransformerGrammar
participant SpanCollector
SourceFile->>TransformerScanner: read_next_declaration()
TransformerScanner->>ChumskyTransformerGrammar: transformer_decl(tokens)
ChumskyTransformerGrammar->>ChumskyTransformerGrammar: match extern transformer Ident ( Params? )
ChumskyTransformerGrammar->>ChumskyTransformerGrammar: expect ':' followed by outputs.at_least(1)
alt missing_colon_or_outputs
ChumskyTransformerGrammar-->>TransformerScanner: ParseError
TransformerScanner->>SpanCollector: skip_line()
SpanCollector-->>TransformerScanner: line_skipped
TransformerScanner-->>SourceFile: record_parse_error_no_transformer
else valid_transformer_declaration
ChumskyTransformerGrammar-->>TransformerScanner: TransformerNode
TransformerScanner-->>SourceFile: record_transformer
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add tests that verify the parser reports errors for missing colons in transformer declarations and that malformed declarations do not prevent parsing subsequent valid declarations. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/differential-datalog-parser-syntax-spec-updated.md`:
- Around line 234-237: The AST crosswalk entry for the Transformer node must be
updated to match the new grammar by adding a field for transformer outputs:
locate the AST crosswalk entry for Transformer (the Transformer node/class/AST
mapping referenced around the existing Transformer grammar) and add an outputs
(or transformerOutputs) field that exposes TransformerOutputs as a list of Ident
(i.e. the comma-separated output identifiers); update any references in the
crosswalk description to include this new outputs field so the spec text aligns
with the grammar.
In `@tests/apply_items.rs`:
- Around line 28-35: Extend the test
transformer_declarations_require_a_colon_before_outputs to verify
newline-bounded recovery: after the malformed line "extern transformer
missing_colon(input: SomeData)" add a newline and then a well-formed transformer
declaration (e.g., "extern transformer good_one(input: SomeData): OutputType")
so parsing should resume; call parse(src) on the combined source, keep the
existing assert_parse_error(parsed.errors(), ...) for the first error, then
assert that parsed.root().transformers() contains the recovered declaration
(check count > 0 and that one transformer has the identifier "good_one" or
equivalent) to prove recovery stops at the newline and records the second
declaration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5af083b6-cb6b-4daf-b854-db4e98e3fe54
📒 Files selected for processing (5)
docs/differential-datalog-parser-syntax-spec-updated.mddocs/parser-conformance-register.mddocs/parser-implementation-notes.mddocs/roadmap.mdtests/apply_items.rs
Added `outputs` field to `TransformerDef` in the Differential Datalog parser syntax specification, describing it as the ordered list of `Ident` values parsed from `TransformerOutputs`. This clarifies the structure of Transformer definitions in documentation. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/apply_items.rs`:
- Around line 29-80: Two tests
(transformer_declarations_require_a_colon_before_outputs and
malformed_transformer_does_not_prevent_parsing_subsequent_declarations)
duplicate the same missing-colon assertions; refactor by adding a helper
function (e.g., assert_missing_colon_error(errors, expected_found)) that
encapsulates the SimpleReason/SyntaxKind::T_COLON checks and then replace the
two tests with a single #[rstest] parameterised test (e.g.,
transformer_missing_colon_behaviour) that takes (src, expected_found,
expected_names) and asserts the missing-colon error via
assert_missing_colon_error and then checks parsed.root().transformers() names;
also add use rstest::rstest import and adjust name mapping to compare
Option<String> values as in the proposed diff.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 68593635-eaba-439a-b7d2-a45acc8cf6c7
📒 Files selected for processing (2)
docs/differential-datalog-parser-syntax-spec-updated.mdtests/apply_items.rs
- Added rstest-based parameterized test to validate missing colon errors in transformer declarations. - Consolidated duplicated test logic into a single parametrized test function. - Improved test coverage for handling malformed transformer declarations and subsequent valid parsers. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
|
@coderabbitai Have the following now been resolved? Annul any requirements that violate the en-GB-oxendict spelling (-ize / -yse / -our) conventions (for example a request to replace "normalize" with "normalise" or "artefact" with "artifact"), or where the requirement unnecessarily increases cyclomatic complexity. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 2297
Overall comment (brittleness): The original
This is substantially more precise and robust against diagnostic-wording changes. Individual comment 1 (recovery test): The
|
Summary
Changes
Documentation updates
docs/differential-datalog-parser-syntax-spec-updated.md
Transformer ::= 'extern' 'transformer' Ident '(' Params? ')' ':' TransformerOutputs
TransformerOutputs ::= Ident (',' Ident)*
docs/parser-conformance-register.md
docs/parser-implementation-notes.md
docs/roadmap.md
Tests
Test plan
◳ Generated by DevBoxer ◰
ℹ️ Tag @devboxerhub to ask questions and address PR feedback
📎 Task: https://www.devboxer.com/task/f3212383-3f9c-465d-8b96-358d66bfc8de
📝 Closes #249
Summary by Sourcery
Align transformer declaration grammar and parser behavior with the documented syntax and mark the roadmap item as implemented.
Enhancements:
Documentation:
Tests: