From 7ff1e525b39a42f94e32c65f8c2aac0a52465dc3 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sat, 7 Oct 2023 15:05:25 +0200 Subject: Added the error message in case of unclosed quote in a text --- lib/qparser/lexbuf.ml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/qparser/lexbuf.ml') diff --git a/lib/qparser/lexbuf.ml b/lib/qparser/lexbuf.ml index 3f0b186..8a3e41c 100644 --- a/lib/qparser/lexbuf.ml +++ b/lib/qparser/lexbuf.ml @@ -18,7 +18,10 @@ let start : t -> unit = t.expression_level <- 0 let positions : t -> Lexing.position * Lexing.position = - fun t -> Sedlexing.lexing_positions t.buffer + fun t -> + let default, end_p = Sedlexing.lexing_positions t.buffer in + let start_p = Option.value ~default t.start_p in + (start_p, end_p) let content : t -> string = fun t -> Sedlexing.Utf8.lexeme t.buffer @@ -27,7 +30,12 @@ let from_lexbuf : ?reset_line:bool -> Sedlexing.lexbuf -> t = { buffer = t; start_p = None; expression_level = 0; reset_line } let set_start_position : t -> Lexing.position -> unit = - fun t position -> t.start_p <- Some position + fun t position -> + match t.start_p with + | None -> t.start_p <- Some position + | _ -> + (* We are already inside a block code, don’t stack it *) + () let tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position = @@ -39,6 +47,7 @@ let tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position let default, curr_p = positions t in let start_p = Option.value ~default t.start_p in + t.start_p <- None; (token, start_p, curr_p) in -- cgit v1.2.3