diff options
author | Chimrod <> | 2023-10-14 15:00:49 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-15 19:04:21 +0200 |
commit | 617d2ee554ccf502c718391aa05b7b72668b83e7 (patch) | |
tree | 3d376be8b5e8d111412602773688e9df81f6143d /lib/qparser/lexer.ml | |
parent | 7ff1e525b39a42f94e32c65f8c2aac0a52465dc3 (diff) |
Added a new error case
Diffstat (limited to 'lib/qparser/lexer.ml')
-rw-r--r-- | lib/qparser/lexer.ml | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/qparser/lexer.ml b/lib/qparser/lexer.ml index 3e1c05b..fe2b487 100644 --- a/lib/qparser/lexer.ml +++ b/lib/qparser/lexer.ml @@ -5,12 +5,9 @@ open Tokens exception UnclosedQuote -exception LexError of Lexing.position * string +exception LexError of string exception EOF -let pp_pos out { Lexing.pos_lnum; pos_cnum; pos_bol; _ } = - Format.fprintf out "line %d:%d" pos_lnum (pos_cnum - pos_bol) - (* Extract the location name from the pattern *) let location_name = Str.regexp {|.* \(.*\)|} @@ -177,14 +174,10 @@ let rec token : Lexbuf.t -> token = | '{' -> LITERAL (wait_balance (read_long_string 0) buffer) | eof -> raise EOF | _ -> - let position = fst @@ Sedlexing.lexing_positions lexbuf in let tok = Lexbuf.content buffer in + let msg = Format.asprintf "Unexpected character %S" tok in - let msg = - Format.asprintf "Unexpected character %S at %a" tok pp_pos position - in - - raise @@ LexError (position, msg) + raise @@ LexError msg let rec discard buffer = let lexbuf = Lexbuf.buffer buffer in |