From 617d2ee554ccf502c718391aa05b7b72668b83e7 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sat, 14 Oct 2023 15:00:49 +0200 Subject: Added a new error case --- lib/qparser/lexer.ml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lib/qparser/lexer.ml') 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 -- cgit v1.2.3