| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** The type of token for the Rocq lexer and parser *) |
| 12 | |
| 13 | type 'c p = |
| 14 | | PKEYWORD : string -> string p |
| 15 | | PIDENT : string option -> string p |
| 16 | | PFIELD : string option -> string p |
| 17 | | PNUMBER : NumTok.Unsigned.t option -> NumTok.Unsigned.t p |
| 18 | | PSTRING : string option -> string p |
| 19 | | PLEFTQMARK : unit p |
| 20 | | PBULLET : string option -> string p |
| 21 | | PQUOTATION : string -> string p |
| 22 | | PEOI : unit p |
| 23 | |
| 24 | val pattern_exact : _ p -> bool |
| 25 | |
| 26 | type t = |
| 27 | | KEYWORD of string |
| 28 | | IDENT of string |
| 29 | | FIELD of string |
| 30 | | NUMBER of NumTok.Unsigned.t |
| 31 | | STRING of string |
| 32 | | LEFTQMARK |
| 33 | | BULLET of string |
| 34 | | QUOTATION of string * string |
| 35 | | EOI |
| 36 | |
| 37 | val equal_p : 'a p -> 'b p -> ('a, 'b) Util.eq option |
| 38 | |
| 39 | (* pass true for diff_mode *) |
| 40 | val extract_string : bool -> t -> string |
| 41 | |
| 42 | (** Names of tokens, used in Grammar error messages *) |
| 43 | |
| 44 | val token_text : 'c p -> string |
| 45 | |
| 46 | (** Utility function for the test returned by a QUOTATION token: |
| 47 | It returns the delimiter parenthesis, if any, and the text |
| 48 | without delimiters. Eg `{{{ text }}}` -> Some '{', ` text ` *) |
| 49 | val trim_quotation : string -> char option * string |
| 50 | |
| 51 | (** for camlp5, |
| 52 | eg [GRAMMAR EXTEND ..... [ IDENT "x" -> .... ] END] |
| 53 | is a pattern (PIDENT (Some "x")) |
| 54 | *) |
| 55 | val match_pattern : 'c p -> t -> 'c option |