File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ open Stdlib
33exception Error of (Lexing. position * Lexing. position) * string
44
55let report_error loc msg =
6- let location = MenhirLib.LexerUtil. range loc in
6+ let location = Lexing. range_to_string loc in
77 Format. eprintf " %s%s%!" location msg;
88 exit 1
99
Original file line number Diff line number Diff line change @@ -1188,3 +1188,19 @@ module Hashtbl = struct
11881188 =
11891189 Hashtbl. of_seq
11901190end
1191+
1192+ module Lexing = struct
1193+ include Lexing
1194+
1195+ let range_to_string (pos1 , pos2 ) =
1196+ if phys_equal pos1 dummy_pos || phys_equal pos2 dummy_pos
1197+ then " At an unknown location:\n "
1198+ else
1199+ let file = pos1.pos_fname in
1200+ let line = pos1.pos_lnum in
1201+ let char1 = pos1.pos_cnum - pos1.pos_bol in
1202+ let char2 = pos2.pos_cnum - pos1.pos_bol in
1203+ (* yes, [pos1.pos_bol] *)
1204+ Printf. sprintf " File \" %s\" , line %d, characters %d-%d:\n " file line char1 char2
1205+ (* use [char1 + 1] and [char2 + 1] if *not* using Caml mode *)
1206+ end
You can’t perform that action at this time.
0 commit comments