diff options
author | Chimrod <> | 2024-01-19 11:55:15 +0100 |
---|---|---|
committer | Chimrod <> | 2024-01-19 11:55:15 +0100 |
commit | 86fd78a5ab65015a9c18ad601856f1b16ed90fa9 (patch) | |
tree | ef47902c248fe385fffbcf6162001aa81748b895 /lib/qparser/lexer.ml | |
parent | c8fb3bdbf3d35c0fd4496d3150961e1fcb202f05 (diff) |
Wait to get a valid syntax before considering a new location
Diffstat (limited to 'lib/qparser/lexer.ml')
-rw-r--r-- | lib/qparser/lexer.ml | 12 |
1 files changed, 8 insertions, 4 deletions
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 |