grammar: open subsystem keys to arbitrary identifiers (closes #64)#68
Merged
Conversation
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.
Closes #64.
The chain manifest grammar was hardcoded to five subsystem keys (
consensus,gas,state,exec,da). A chain wanting to declare a new axis (privacy, MEV protection, cross-chain bridging, anything we did not anticipate) could not. This PR lifts that.What changed
Parser
`is_subsystem_key` now accepts `TK_IDENT` in addition to the five reserved keyword tokens. Any identifier is a valid subsystem key. The five names stay as keyword tokens because `state` and `gas` also start module-item declarations elsewhere in the grammar.
Grammar spec
`spec/grammar.ebnf`: `SubsystemKey = IDENT` instead of the enumerated list. The five names are documented as the stdlib axes, but no longer parser-level requirements.
Tree-sitter
`cleave-lang/tree-sitter-cleave` updated in the same change so the two grammars stay in lockstep. `subsystem_key` becomes `$.identifier` instead of a fixed-choice rule. Test corpus fixtures updated to expect the new `(subsystem_key (identifier))` shape.
Tests
`test_error_unknown_subsystem_key` deleted. It asserted that `unknown: ...` errors; after this PR that's the intended behavior. Replaced with two positive tests:
154 parser assertions (was 149).
End-to-end demo
```cleave
// This parses now (previously rejected)
chain MyZkChain {
consensus: Tendermint<sig=BLS12_381>
gas: Multidim<{cpu, storage, witness}>
state: SparseMerkle<key=u256, hash=Blake3>
exec: WasmVM
da: NativeDA
privacy: GrothProver<curve=BN254>
mev: FlashbotsBundler
bridge: CelestiaIBC
}
```
What this PR does NOT do
This PR is just the parser-layer lift. The full third-party extensibility story needs the three follow-ups above.
What unblocks next