runtimeverification / runtimeverification/mir-semantics
Support struct-like variants in `parser.py`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 52
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Consider
pub enum VariantsShape {
Single { index: VariantIdx },
Multiple {
tag: Scalar,
tag_encoding: TagEncoding,
tag_field: usize,
variants: Vec<LayoutShape>,
},
}
This can be modeled with proper parser support in K as follows:
syntax VariantsShape ::= variantsShapeSingle(VariantsShapeSingle) [group(mir-enum), symbol(VariantsShape::Single)]
| variantsShapeMultiple(VariantsShapeMultiple) [group(mir-enum), symbol(VariantsShape::Multiple)]
syntax VariantsShapeSingle ::= mk(index: VariantIdx) [group(mir---index)]
syntax VariantsShapeMultiple ::= mk ( tag: Scalar
, tagEncoding: TagEncoding
, tagField: MIRInt
, variants: LayoutShapes
) [group(mir---tag--tag-encoding--tag-field--variants)]
The ideal solution would be to eliminate the mk constructors, and model the struct-like variants directly, e.g.:
syntax VariantsShape ::= variantsShapeSingle(index: VariantIdx) [group(mir-enum---index), symbol(VariantsShape::Single)]
| variantsShapeMultiple ( tag: Scalar
, tagEncoding: TagEncoding
, tagField: MIRInt
, variants: LayoutShapes
) [group(mir-enum---tag--tag-encoding--tag-field--variants), symbol(VariantsShape::Multiple)]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in parser.py and compare the existing handling of enum variants with the VariantsShape examples in the issue. Determine how the Single and Multiple fields map into the parser's K syntax, then verify that both struct-like forms are accepted and represented correctly. The ideal completion removes the intermediate mk constructors where possible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100