From 86fd78a5ab65015a9c18ad601856f1b16ed90fa9 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 19 Jan 2024 11:55:15 +0100 Subject: Wait to get a valid syntax before considering a new location --- lib/qparser/lexer.ml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/qparser/lexer.ml') diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index 30d151b..4e9aa27 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -188,16 +188,20 @@ let rec parse_token : Lexbuf.t -> token = | '#', Star space, location -> (* Extract the location name *) let ident = Lexbuf.content buffer in - let () = + let ident_name = match Str.string_match location_name ident 0 with - | false -> () - | true -> Sedlexing.set_filename lexbuf (Str.matched_group 1 ident) + | false -> ident + | true -> Str.matched_group 1 ident in (* Restart the line number (new location here) *) Lexbuf.start buffer; - LOCATION_START ident + LOCATION_START + (fun () -> + Sedlexing.set_filename lexbuf ident_name; + (* Restart the line number (new location here) *) + ident_name) | '_', Star space, eol, Star space -> (* The _ character can be used to break lines *) parse_token buffer -- cgit v1.2.3