2197: tpattern_comma_list: 2198: | tpattern COMMA tpattern_comma_list { $1 :: $3 } 2199: | tpattern { [$1] } 2200: | { [] } 2201: 2202: tuple_tpattern: 2203: | tpattern_comma_list { 2204: match $1 with 2205: | _ :: _ :: _ -> `TPAT_type_tuple $1 2206: | x :: [] -> x 2207: | [] -> assert false 2208: } 2209: 2210: tpattern: 2211: | tpattern AS NAME { `TPAT_as ($1,snd $3) } 2212: | tpat0 { $1 } 2213: 2214: tpat0: 2215: | tpat1 RIGHTARROW tpat0 { `TPAT_function ($1,$3) } 2216: | tpat1 { $1 } 2217: 2218: tpat1: 2219: | sumpat 2220: { 2221: match $1 with 2222: | [x] -> x 2223: | ps -> `TPAT_sum ps 2224: } 2225: 2226: sumpat: 2227: | tpat2 PLUS sumpat { $1 :: $3 } 2228: | tpat2 { [$1] } 2229: 2230: tpat2: 2231: | mulpat 2232: { 2233: match $1 with 2234: | [x] -> x 2235: | ps -> `TPAT_tuple ps 2236: } 2237: 2238: mulpat: 2239: | tpat3 STAR mulpat { $1 :: $3 } 2240: | tpat3 { [$1] } 2241: 2242: tpat3: 2243: | NAME tpatlist { `TPAT_name (snd $1, $2) } 2244: | LPAR tuple_tpattern RPAR { $2 } 2245: | QUEST NAME { `TPAT_var (snd $2) } 2246: | QUEST { `TPAT_any } 2247: | UNDERSCORE { `TPAT_any } 2248: | INTEGER { let sr,t,v = $1 in `TPAT_unitsum (Big_int.int_of_big_int v) } 2249: 2250: tpatlist: 2251: | LSQB tpattern_comma_list RSQB { $2 } 2252: | { [] } 2253: 2254: 2255: type_match_expr: 2256: | TYPEMATCH expr WITH type_matchings ENDMATCH 2257: { 2258: let t = typecode_of_expr $2 in 2259: `AST_type_match (rstoken $1 $5, (t, $4)) 2260: } 2261: 2262: type_matchings: 2263: | type_matching type_matchings { $1 :: $2 } 2264: | type_matching { [$1] } 2265: 2266: type_matching: 2267: | VBAR tuple_tpattern EQRIGHTARROW expr { $2, typecode_of_expr $4 } 2268: