Repository navigation
test: grammar conformance harness — pest shadow grammar + EDN corpus (#233) - #235
Merged
Merged
Conversation
Covers corpus layout (valid/invalid/syntax/invalid/semantic), pest shadow grammar scope, three-bucket conformance test logic, and Cargo changes. Resolves the open design question for issue #230 pre-implementation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add pest/pest_derive dev-dependencies, corpus directory structure (tests/grammar/valid, invalid/syntax, invalid/semantic), placeholder grammar.pest, and the full three-bucket conformance test harness. Tests fail with "corpus is empty" as expected until fixtures are added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Task 7) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10 .edn files in tests/grammar/invalid/syntax/ that are rejected by both the pest grammar and the real Minigraf parser. Note: the spec suggested not_join_no_clauses.edn but pest's rule_invocation fallthrough accepts (not-join [?e]), so the 10th file is transact_no_args.edn ((transact) with no argument) which both parsers structurally reject. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 fixture files where pest accepts (structural syntax is valid) but the real Minigraf parser rejects (semantic check fails): not-safety violations, nested not/or-inside-not, not-join unbound join vars, unbound expr/aggregate/:with variables, :with without aggregate, window-only func without :over, non-window func with :over, fact too-few elements, retract wrong arity, invalid UUID format. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
pestPEG shadow grammar (tests/grammar/grammar.pest) encoding the full structural Minigraf Datalog syntax as an executable spec.edncorpus: 31 valid fixtures, 10 syntax-error fixtures, 13 semantic-error fixturestests/grammar_conformance.rswith three#[test]functions (valid_corpus,invalid_syntax_corpus,invalid_semantic_corpus) that sweep the corpus and verify the three-bucket contract against both parsers.wiki/Datalog-Reference.md(wiki already updated)pest/pest_deriveadded to[dev-dependencies]only — zero production impactCloses #233. Sub-issue of #230.
Three-bucket contract
valid/invalid/syntax/invalid/semantic/The conformance harness fails CI the moment the grammar doc and parser disagree on any corpus fixture.
Notable implementation detail
The
factrule is permissive ("[" ~ edn_value+ ~ "]") so that under-arity and over-arity facts land ininvalid/semantic/(the real parser enforces the[E A V]/[E A V {map}]shape), notinvalid/syntax/. This preserves the three-bucket taxonomy correctly.Test plan
cargo test --test grammar_conformance— all 3 tests pass (31 valid + 10 syntax + 13 semantic fixtures)cargo test) — 538 tests pass, 0 failurescargo clippy --tests— clean🤖 Generated with Claude Code