Unify match and match_switch into single match syntax#75
Open
DominicPM wants to merge 1 commit intoawslabs:mainfrom
Open
Unify match and match_switch into single match syntax#75DominicPM wants to merge 1 commit intoawslabs:mainfrom
DominicPM wants to merge 1 commit intoawslabs:mainfrom
Conversation
909d4d7 to
ce1607b
Compare
Users now write `match` for all pattern matching - both algebraic patterns (constructors, tuples) and numeric patterns (0, 1, numerals). The system automatically dispatches to the appropriate backend: - Algebraic patterns → HOL case expression (bcase) - Numeric patterns → numeric case selector (ncase) The dispatch logic analyzes patterns at the AST level: - If any pattern has constructor arguments or is a tuple → algebraic - If any pattern is a numeric literal AND all patterns are switch- compatible (no constructor args) → switch - Otherwise → algebraic (default) Changes: - Remove user-facing `match_switch` syntax (internal `_urust_match_switch` retained for implementation) - Add pattern classification that handles disjunctions recursively - Add comprehensive `value[simp]` tests verifying numeric match evaluation - Test coverage for different word sizes, larger numerals, disjunctive numeric patterns Signed-off-by: Dominic Mulligan <dominic.p.mulligan@gmail.com>
ce1607b to
b04f218
Compare
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.
Users now write
matchfor all pattern matching - both algebraic patterns (constructors, tuples) and numeric patterns (0, 1, numerals). The system automatically dispatches to the appropriate backend:The dispatch logic analyzes patterns at the AST level:
Changes:
match_switchsyntax (internal_urust_match_switchretained for implementation)value[simp]tests verifying numeric match evaluationBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.