Module CLexer

type starts_quotation =
| NoQuotation
| Quotation

When one registers a keyword she can declare it starts a quotation. In particular using QUOTATION("name:") in a grammar rule declares "name:" as a keyword and the token QUOTATION is matched whenever the keyword is followed by an identifier or a parenthesized text. Eg

constr:x string:.... ltac:(....) ltac:....

The delimiter is made of 1 or more occurrences of the same parenthesis, eg ((.....)) or [[[....]]]. The idea being that if the text happens to contain the closing delimiter, one can make the delimiter longer and avoid confusion (no escaping). Eg

string:[ .. ']' .. ]

Nesting the delimiter is allowed, eg ((..((...))..)) is OK.

Keywords don't need to end in ':'

val add_keyword : ?⁠quotation:starts_quotation -> string -> unit

This should be functional but it is not due to the interface

val remove_keyword : string -> unit
val is_keyword : string -> bool
val keywords : unit -> CString.Set.t
type keyword_state
val set_keyword_state : keyword_state -> unit
val get_keyword_state : unit -> keyword_state
val check_ident : string -> unit
val is_ident : string -> bool
val check_keyword : string -> unit
val terminal : string -> string Tok.p

When string is not an ident, returns a keyword.

val terminal_numeral : string -> NumTok.t Tok.p

Precondition: the input is a numeral (c.f. NumTok.t)

module Lexer : Gramlib.Grammar.GLexerType with type te = Tok.t and type 'c pattern = 'c Tok.p
module Error : sig ... end
type lexer_state
val init_lexer_state : unit -> lexer_state
val set_lexer_state : lexer_state -> unit
val get_lexer_state : unit -> lexer_state
val drop_lexer_state : unit -> unit
val get_comment_state : lexer_state -> ((int * int) * string) list
module LexerDiff : Gramlib.Grammar.GLexerType with type te = Tok.t and type 'c pattern = 'c Tok.p

Create a lexer. true enables alternate handling for computing diffs. It ensures that, ignoring white space, the concatenated tokens equal the input string. Specifically: