diff options
| author | Alastair Reid | 2018-07-25 18:42:26 +0100 |
|---|---|---|
| committer | Alastair Reid | 2018-07-26 13:14:33 +0100 |
| commit | 92373cfb9dd6a9a3d450a315d462378b7de20a71 (patch) | |
| tree | 33e2c2f257d5d18e0e4371912176e05c805b4c70 /src/parser.mly | |
| parent | 86e29bcbb1597c4ef1f6cae8edbeed42f9a31414 (diff) | |
Patterns: add or and not patterns
These match the new ASL pattern constructors:
- !p matches if the pattern p does not match
- { p1, ... pn } matches if any of the patterns p1 ... pn match
We desugar the set pattern "{p1, ... pn}" into "p1 | (p2 | ... pn)".
ASL does not have pattern binding but Sail does. The rules at the
moment are that none of the pattern can contain patterns. This could
be relaxed by allowing "p1 | p2" to bind variables provided p1 and p2
both bind the same variables.
Diffstat (limited to 'src/parser.mly')
| -rw-r--r-- | src/parser.mly | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/parser.mly b/src/parser.mly index 0637d61a..2a05c013 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -710,6 +710,8 @@ atomic_pat: { mk_pat (P_lit $1) $startpos $endpos } | id { mk_pat (P_id $1) $startpos $endpos } + | pat Bar pat + { mk_pat (P_or ($1, $3)) $startpos $endpos } | kid { mk_pat (P_var (mk_pat (P_id (id_of_kid $1)) $startpos $endpos, mk_typ (ATyp_var $1) $startpos $endpos)) $startpos $endpos } |
