Utiliser le mode texte pour copier les morceaux de l'entree vers la
sortie (evite les \r\r\n a la fin des lignes sous Windows). git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1213 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
3eb8f1b467
commit
29fdaf2ba9
10
lex/main.ml
10
lex/main.ml
|
@ -28,9 +28,10 @@ let main () =
|
|||
Filename.chop_suffix source_name ".mll" ^ ".ml"
|
||||
else
|
||||
source_name ^ ".ml" in
|
||||
let ic = open_in_bin source_name in
|
||||
let ic_bin = open_in_bin source_name in
|
||||
let ic_txt = open_in source_name in
|
||||
let oc = open_out dest_name in
|
||||
let lexbuf = Lexing.from_channel ic in
|
||||
let lexbuf = Lexing.from_channel ic_bin in
|
||||
let def =
|
||||
try
|
||||
Parser.lexer_definition Lexer.main lexbuf
|
||||
|
@ -53,8 +54,9 @@ let main () =
|
|||
exit 2 in
|
||||
let (entries, transitions) = Lexgen.make_dfa def in
|
||||
let tables = Compact.compact_tables transitions in
|
||||
Output.output_lexdef ic oc def.header tables entries def.trailer;
|
||||
close_in ic;
|
||||
Output.output_lexdef ic_txt oc def.header tables entries def.trailer;
|
||||
close_in ic_bin;
|
||||
close_in ic_txt;
|
||||
close_out oc
|
||||
|
||||
let _ = Printexc.catch main (); exit 0
|
||||
|
|
|
@ -20,16 +20,11 @@ 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 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
|
||||
let buffer = String.create (stop - start) in
|
||||
let r = input ic buffer 0 (stop - start) in
|
||||
output oc buffer 0 r
|
||||
|
||||
(* To output an array of short ints, encoded as a string *)
|
||||
|
||||
|
|
Loading…
Reference in New Issue