From 916d37b93c8ad0e2fbe98377093726baf051b708 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Mon, 5 Feb 2024 09:32:10 +0100 Subject: Ignore the global checkers if there is a syntax error; ignore error during recovery after a syntax error --- lib/qparser/lexbuf.ml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/qparser/lexbuf.ml') diff --git a/lib/qparser/lexbuf.ml b/lib/qparser/lexbuf.ml index 1d93f67..afc3bac 100644 --- a/lib/qparser/lexbuf.ml +++ b/lib/qparser/lexbuf.ml @@ -5,6 +5,7 @@ type t = { mutable start_p : Lexing.position option; state : state Stack.t; reset_line : bool; + mutable recovering : bool; } and lexer = t -> Tokens.token @@ -50,7 +51,8 @@ let start : t -> unit = Sedlexing.set_position t.buffer { end_pos with Lexing.pos_lnum = 1 } in Stack.clear t.state; - t.start_p <- None + t.start_p <- None; + t.recovering <- false let positions : t -> Lexing.position * Lexing.position = fun t -> @@ -62,7 +64,13 @@ let content : t -> string = fun t -> Sedlexing.Utf8.lexeme t.buffer let from_lexbuf : ?reset_line:bool -> Sedlexing.lexbuf -> t = fun ?(reset_line = true) t -> - { buffer = t; start_p = None; reset_line; state = Stack.create () } + { + buffer = t; + start_p = None; + reset_line; + state = Stack.create (); + recovering = false; + } let set_start_position : t -> Lexing.position -> unit = fun t position -> @@ -97,3 +105,6 @@ let overlay : t -> lexer -> lexer = match layer with | String wraper | EndString wraper -> wraper.start_string acc | _ -> acc) + +let start_recovery : t -> unit = fun t -> t.recovering <- true +let is_recovery : t -> bool = fun t -> t.recovering -- cgit v1.2.3