aboutsummaryrefslogtreecommitdiff
path: root/lib/qparser/lexbuf.mli
blob: ec94d1bb72e7acb67edbc1826096222f092dbcf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(** Lexing buffer. *)

type t
(** The state of the buffer *)

val from_lexbuf : ?reset_line:bool -> Sedlexing.lexbuf -> t
(** Create a new buffer *)

val start : t -> unit
(** Intialize a new run *)

val buffer : t -> Sedlexing.lexbuf
(** Extract the sedlex buffer. Required in each rule. *)

val positions : t -> Lexing.position * Lexing.position
(** Extract the starting and ending position for the matched token *)

val content : t -> string
(** Extract the token matched by the rule *)

val set_start_position : t -> Lexing.position -> unit
(** Reset the starting position. Used while parsing the string to keep the
    begining of the whole string. *)

val tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position
(** Function to use in the parser in order to extract the token match, and the
    starting and ending position. *)

val rollback : t -> unit
(** Rollback the latest token matched *)

(** {1 State in expressions} *)

type state =
  | Token
  | String
  | DString
  | MString of int
  | EndString
  | Expression

val state : t -> state option
(** Get the current state for the lexer *)

val enter_state : t -> state -> unit
(** Enter into a new state *)

val leave_state : t -> unit
(** Leave the current state *)