diff options
author | Chimrod <> | 2024-02-05 09:32:10 +0100 |
---|---|---|
committer | Chimrod <> | 2024-02-08 14:16:41 +0100 |
commit | 916d37b93c8ad0e2fbe98377093726baf051b708 (patch) | |
tree | e8c6b77368fb8971af11a425ac61e0b3e2014beb /lib/qparser/lexbuf.ml | |
parent | d7a13b0e5d6e746993e67a291376bd79766e0ed1 (diff) |
Ignore the global checkers if there is a syntax error; ignore error during recovery after a syntax error
Diffstat (limited to 'lib/qparser/lexbuf.ml')
-rw-r--r-- | lib/qparser/lexbuf.ml | 15 |
1 files changed, 13 insertions, 2 deletions
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 |