[spectec] Define IL semantics for pattern matching#2106
[spectec] Define IL semantics for pattern matching#2106
Conversation
|
There is a typo in the Additionally, I have a question regarding the |
|
@jihongmin63, thanks, typo is fixed. Regarding signs, the rules require that the l.h.s. has already been reduced to a plain number, which you could think of as normalising signs because they are internalised into the number, i.e. can't be unops anymore. The rules just check their signs and then proceed with the absolute value of the number. (Not sure if that answers your question.) |
This formalises SpecTec IL pattern matching.
Turned out to be a bit more tricky than anticipated. Usually in a small-step semantics, pattern matching is formulated by iteratively reducing a match expression, ideally using evaluation context to focus on the next subpattern to consider. In SpecTec we neither (a) have match expressions, nor (b) can use evaluation contexts.
To address (a), I introduced a match expression, as a sort of administrative expression (we could discuss making it a regular part of the IL), such that function application first reduces into a match. To handle type family application, an analogous approach is used for type reduction. To address (b), the match forms can match sequences of arguments; this allows the equivalent of a "bubbling" semantics, by iteratively splitting matches into more sub-matches, until pattern variables reach the top.
Other changes:
iine^(i<n));_or a fresh variable is equivalent.@DCupello1, @sukyoung, @zilinc, @jihongmin63, @conrad-watt, @slindley