Grammar coverage: multiple superclasses, sort-annotated & Greek type variables#8
Merged
Conversation
TYPE_IDENT only matched ASCII type variables (`'a`), so type variables written with Greek symbols (`'\<alpha>`, `'\<beta>`) — common in the AFP — were rejected wherever type variables appear (type_synonym, datatype, typedef, …). Extend TYPE_IDENT to allow a `\<name>` symbol after the apostrophe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
class_spec only allowed a single parent class name before the context elements, so `class c = foo + bar + linorder` (a chain of superclasses, common in algebraic-hierarchy entries) failed. Allow a `+`-separated list of parent class names, optionally followed by `+ <context elements>`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`datatype` used `generic_type` for its left-hand side, which treats type
arguments as opaque types and rejects sort annotations like
`datatype ('a::type) box = ...`. Switch to `typespec_sorts`, which is the
correct shape for a type specification (`(tvar::sort, ...) name`) and
already handles plain and Greek type variables.
Verified against a corpus sample of real datatype declarations: 0 new
regressions vs the previous grammar (one additional declaration now
parses). Full unit suite green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
christiankissig
added a commit
that referenced
this pull request
Jul 7, 2026
Grammar coverage: multiple superclasses, sort-annotated & Greek type variables
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
Closes the three highest-value form-level gaps identified in the refreshed coverage report (target "A"). All three were confirmed failing in isolation and are localized grammar changes.
type_synonym ('\<alpha>, '\<beta>) t = …TYPE_IDENTextended to allow a\<name>symbol after'— applies everywhere type vars occurclassclass c = foo + bar + linorderclass_specnow accepts a+-separated list of parent class names, optionally followed by+ <context elements>datatypedatatype ('a::type) box = …datatypenow usestypespec_sorts(the correct(tvar::sort, …) nameshape) instead ofgeneric_typeTesting
datatypedeclarations: 0 new regressions vs the previous grammar (one extra declaration now parses). The pre-existing failures there are bnf-style annotations (dead 'd,leaves: 'l) unrelated to this change.ruff check/ruff format/isortclean.Not included
dead, selectorname:on type args),method … for …,unbundle (in …), and thenominal_*command family remain unsupported (niche; noted in COVERAGE_REPORT.md).🤖 Generated with Claude Code