2298: match_expr:
2299: | MATCH expr WITH matchings ENDMATCH
2300: {
2301: `AST_match (rstoken $1 $5, ($2, $4))
2302: }
2303: matchings:
2304: | matching matchings { $1 :: $2 }
2305: | matching { [$1] }
2306: matching:
2307: | VBAR pattern EQRIGHTARROW expr { $2, $4 }
2308: | VBAR EQRIGHTARROW expr { let sr = rstoken $1 $2 in `PAT_none sr, $3 }
2309:
2310: typecaseargs:
2311: | LSQB basic_name_comma_list RSQB { $2 }
2312:
2313: typecase:
2314: | TYPECASE typecaseargs expr EQRIGHTARROW expr ENDCASE
2315: {
2316: let sr = rstoken $1 $6 in
2317: let t1 = $3 in
2318: let t2 = $5 in
2319: let ls = map snd $2 in
2320: `AST_case (sr,t1,ls,t2)
2321: }
2322:
The pattern matching statment analyses the shape and contents of
a value and selects the first matching case from the matching body.