diff options
author | Chimrod <> | 2025-03-24 14:53:54 +0100 |
---|---|---|
committer | Chimrod <> | 2025-03-24 14:53:54 +0100 |
commit | 682a09b377ae85de6b59b481af4b7d0812f4b456 (patch) | |
tree | da627b5ab15bd9b72200c96638aee2ef31c5aa98 /lib | |
parent | 23bcff2eaf5938acc04507636698c034c4767a1e (diff) |
In case of identified error, leave the state properly at the end of the location
Diffstat (limited to 'lib')
-rw-r--r-- | lib/qparser/lexbuf.ml | 2 | ||||
-rw-r--r-- | lib/qparser/lexbuf.mli | 3 | ||||
-rw-r--r-- | lib/qparser/lexer.ml | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/qparser/lexbuf.ml b/lib/qparser/lexbuf.ml index dbed622..9ba7938 100644 --- a/lib/qparser/lexbuf.ml +++ b/lib/qparser/lexbuf.ml @@ -41,6 +41,7 @@ let pp_state format = function let state : t -> state option = fun t -> Stack.top_opt t.state let enter_state : t -> state -> unit = fun t state -> Stack.push state t.state let leave_state : t -> unit = fun t -> ignore @@ Stack.pop_opt t.state +let clear_state : t -> unit = fun t -> Stack.clear t.state let buffer : t -> Sedlexing.lexbuf = fun t -> t.buffer let start : t -> unit = @@ -92,6 +93,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.recovering <- false; t.start_p <- None; (token, start_p, curr_p) diff --git a/lib/qparser/lexbuf.mli b/lib/qparser/lexbuf.mli index d656642..8beb9da 100644 --- a/lib/qparser/lexbuf.mli +++ b/lib/qparser/lexbuf.mli @@ -82,6 +82,9 @@ val enter_state : t -> state -> unit val leave_state : t -> unit (** Leave the current state *) +val clear_state : t -> unit +(** Remove all the elements from the stack *) + val overlay : t -> lexer -> lexer val start_recovery : t -> unit diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index 470cdc7..0bd214a 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -347,7 +347,6 @@ let rec discard buffer = We are here because an error was raised, so can have any situation (for example a missing quote). *) - leave_expression buffer; - () + Lexbuf.clear_state buffer | any -> discard buffer | _ -> raise EOF |