set the filename in the lexbuf

This commit is contained in:
Jeremie Dimino 2013-07-12 12:02:18 +01:00
parent 586bfbdc04
commit e02a18b4d7
1 changed files with 15 additions and 11 deletions

View File

@ -194,17 +194,21 @@ let input_name = "//toplevel//"
let lexbuf_of_string eof str = let lexbuf_of_string eof str =
let pos = ref 0 in let pos = ref 0 in
Lexing.from_function let lexbuf =
(fun buf len -> Lexing.from_function
if !pos = String.length str then begin (fun buf len ->
eof := true; if !pos = String.length str then begin
0 eof := true;
end else begin 0
let len = min len (String.length str - !pos) in end else begin
String.blit str !pos buf 0 len; let len = min len (String.length str - !pos) in
pos := !pos + len; String.blit str !pos buf 0 len;
len pos := !pos + len;
end) len
end)
in
Location.init lexbuf input_name;
lexbuf
let mkloc loc = let mkloc loc =
(loc.Location.loc_start.Lexing.pos_cnum, (loc.Location.loc_start.Lexing.pos_cnum,