Remove =x uses from ISLE, and remove support from the DSL compiler. (#4078)

This is a follow-up on #4074: now that we have the simplified syntax, we
can remove the old, redundant syntax.
This commit is contained in:
Chris Fallin
2022-04-28 11:17:08 -07:00
committed by GitHub
parent 477d394288
commit eceb433b28
8 changed files with 78 additions and 89 deletions

View File

@@ -498,16 +498,16 @@ operators:
`0x80`, `-0x80`) and boolean constants (`#t`, `#f`).
* constants imported from the embedding, of arbitrary type
(`$MyConst`).
* Variable captures (bare identifiers like `x`; an identifier consists
of alphanumeric characters and underscores, and does not start with
a digit).
* Variable captures and matches (bare identifiers like `x`; an
identifier consists of alphanumeric characters and underscores, and
does not start with a digit). The first occurrence of a variable `x`
captures the value; each subsequent occurrence matches on the
already-captured value, rejecting the match if not equal.
* Variable captures with sub-patterns: `x @ PAT`, which captures the
subterm in `x` as above but also matches `PAT` against the
subterm. For example, `x @ (A y z)` matches an `A` term and captures
its arguments as `y` and `z`, but also captures the whole term as
`x`.
* "Equal-variable" constraints (`=x`): a subterm must match an
already-captured value.
* conjunctions of subpatterns: `(and PAT1 PAT2 ...)` matches all of
the subpatterns against the term. If any subpattern does not match,
then this matcher fails.
@@ -680,12 +680,11 @@ The typing rules for patterns in ISLE are:
T2 T2) R)`, has type `R` and provides expected types `T1`, `T2`, and
`T3` to its subpatterns.
* A variable capture pattern `x` is compatible with any expected type,
and captures this expected type under the variable identifier `x` in
the type environment.
* A variable-equality pattern `=x` checks that the expected type is
equal to the already-captured type for `x` in the type environment.
* A variable capture pattern `x` is compatible with any expected type
the first time it appears, and captures this expected type under the
variable identifier `x` in the type environment. Subsequent
appearances of `x` check that the expected type matches the
already-captured type.
* A conjunction `(and PAT1 PAT2 ...)` checks that each subpattern is
compatible with the expected type.
@@ -1397,7 +1396,7 @@ newline). The grammar accepted by the parser is as follows:
<pattern> ::= <int>
| <const-ident>
| "_"
| "=" <ident>
| <ident>
| <ident> "@" <pattern>
| "(" "and" <pattern>* ")"
| "(" <ident> <pattern-arg>* ")"

View File

@@ -20,7 +20,7 @@
(and
a
(Ext1 x)
(Ext2 =x)))
(Ext2 x)))
(C #t))
(type Opcode (enum A B C))
@@ -39,4 +39,4 @@
(decl F (Opcode) u32)
(rule
(F _)
$B)
$B)

View File

@@ -411,23 +411,13 @@ impl<'a> Parser<'a> {
Ok(Pattern::Wildcard { pos })
} else if self.is_sym() {
let s = self.symbol()?;
if s.starts_with("=") {
// Deprecated `=x` syntax. This will go away once we
// change all uses to just `x`, which we can do
// because we disambiguate whether a mention of `x` is
// a binding or a matching of the already-bound value.
let s = &s[1..];
let var = self.str_to_ident(pos, s)?;
Ok(Pattern::Var { var, pos })
let var = self.str_to_ident(pos, &s)?;
if self.is_at() {
self.at()?;
let subpat = Box::new(self.parse_pattern()?);
Ok(Pattern::BindPattern { var, subpat, pos })
} else {
let var = self.str_to_ident(pos, &s)?;
if self.is_at() {
self.at()?;
let subpat = Box::new(self.parse_pattern()?);
Ok(Pattern::BindPattern { var, subpat, pos })
} else {
Ok(Pattern::Var { var, pos })
}
Ok(Pattern::Var { var, pos })
}
} else if self.is_lparen() {
self.lparen()?;