File: ast_pattern0.ml

package info (click to toggle)
ppxlib 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 1,284 kB
  • sloc: ml: 17,184; sh: 149; makefile: 36; python: 36
file content (20 lines) | stat: -rw-r--r-- 622 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open! Import

exception Expected of Location.t * string

let fail loc expected =
  raise (Expected (loc, expected))
;;

type context =
  { (* [matched] counts how many constructors have been matched. This is used to find what
       pattern matches the most some piece of ast in [Ast_pattern.alt]. In the case where
       all branches fail to match, we report the error from the one that matches the
       most.

       This is only incremented by combinators that can fail. *)
    mutable matched : int
  }

type ('matched_value, 'k, 'k_result) t =
    T of (context -> Location.t -> 'matched_value -> 'k -> 'k_result)