Skip to content

Commit 594c534

Browse files
authored
[spectec] Add fail rule for str match in IL semantics (#2122)
1 parent 811f86a commit 594c534

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

spectec/doc/semantics/il/1-syntax.spectec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ syntax exp =
115115
| LIST exp* ;; [ exp* ]
116116
| LIFT exp ;; exp : _? <: _*
117117
| STR expfield* ;; { expfield* }
118-
| SEL exp nat ;; exp.i
118+
| SEL exp nat ;; exp.n
119119
| LEN exp ;; | exp |
120120
| MEM exp exp ;; exp `<-` exp
121121
| CAT exp exp ;; exp `++` exp
122122
| ACC exp path ;; exp[ path ]
123123
| UPD exp path exp ;; exp[ path = exp ]
124124
| EXT exp path exp ;; exp[ path =.. exp ]
125125
| CALL id arg* ;; defid( arg* )
126-
| ITER exp iter exppull* ;; exp iter{ expiter* }
127-
| CVT exp numtyp numtyp ;; exp : typ1 <:> typ2
126+
| ITER exp iter exppull* ;; exp iter{ exppull* }
127+
| CVT exp numtyp numtyp ;; exp : numtyp1 <:> numtyp2
128128
| SUB exp typ typ ;; exp : typ1 <: typ2
129129
| MATCH arg* WITH clause* ;; `match` arg* `with` clause*
130130

@@ -149,7 +149,7 @@ syntax sym =
149149
| SEQ sym* ;; sym*
150150
| ALT sym* ;; sym `|` sym
151151
| RANGE sym sym ;; sym `|` `...` `|` sym
152-
| ITER sym iter exppull* ;; sym iter{ expiter* }
152+
| ITER sym iter exppull* ;; sym iter{ exppull* }
153153
| ATTR exp sym ;; exp `:` sym
154154

155155

spectec/doc/semantics/il/5-reduction.spectec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,9 @@ rule Step_expmatch_plain/STR:
697697
-- (if (l `= e') = ef')*
698698
-- (if (l `= e) <- ef*)*
699699

700+
rule Step_expmatch_plain/STR-fail:
701+
S |- STR ef* / STR ef'* ~> FAIL
702+
-- otherwise
700703

701704
rule Step_expmatch_plain/ITER-PLUS:
702705
S |- LIST e* / ITER e' PLUS (x `: t `<- e_p)* ~>

0 commit comments

Comments
 (0)