Retour en arriere sur le traitement des fins de lignes

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1216 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1996-12-10 10:42:07 +00:00
parent fd9e9cd859
commit fa45b038f6
2 changed files with 12 additions and 9 deletions

View File

@ -28,10 +28,9 @@ let main () =
Filename.chop_suffix source_name ".mll" ^ ".ml"
else
source_name ^ ".ml" in
let ic_bin = open_in_bin source_name in
let ic_txt = open_in source_name in
let ic = open_in_bin source_name in
let oc = open_out dest_name in
let lexbuf = Lexing.from_channel ic_bin in
let lexbuf = Lexing.from_channel ic in
let def =
try
Parser.lexer_definition Lexer.main lexbuf
@ -54,9 +53,8 @@ let main () =
exit 2 in
let (entries, transitions) = Lexgen.make_dfa def in
let tables = Compact.compact_tables transitions in
Output.output_lexdef ic_txt oc def.header tables entries def.trailer;
close_in ic_bin;
close_in ic_txt;
Output.output_lexdef ic oc def.header tables entries def.trailer;
close_in ic;
close_out oc
let _ = Printexc.catch main (); exit 0

View File

@ -20,11 +20,16 @@ open Compact
(* To copy the ML code fragments *)
let copy_buffer = String.create 1024
let copy_chunk ic oc (Location(start,stop)) =
seek_in ic start;
let buffer = String.create (stop - start) in
let r = input ic buffer 0 (stop - start) in
output oc buffer 0 r
let n = ref (stop - start) in
while !n > 0 do
let m = input ic copy_buffer 0 (min !n 1024) in
output oc copy_buffer 0 m;
n := !n - m
done
(* To output an array of short ints, encoded as a string *)