https://github.com/charguer/ocaml
Revision 272d5404b739ea5876d10292efca711cb16a5f8c authored by Xavier Leroy on 30 November 1999, 15:56:46 UTC, committed by Xavier Leroy on 30 November 1999, 15:56:46 UTC
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/ocaml2@2650 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent 507c17b
Tip revision: 272d5404b739ea5876d10292efca711cb16a5f8c authored by Xavier Leroy on 30 November 1999, 15:56:46 UTC
Correction du bug signale par C.Rinderknecth (composantes mal calculees pour un module dont le type est un nom de type de module defini dans le meme module)
Correction du bug signale par C.Rinderknecth (composantes mal calculees pour un module dont le type est un nom de type de module defini dans le meme module)
Tip revision: 272d540
cvt_emit.mll
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id$ *)
{
let first_item = ref false
let command_beginning = ref 0
let add_semicolon () =
if !first_item
then first_item := false
else print_string "; "
let print_unescaped_string s =
let l = String.length s in
let i = ref 0 in
while !i < l do
if s.[!i] = '\\'
&& !i+1 < l
&& (let c = s.[!i+1] in c = '{' || c = '`') (* ` *)
then i := !i+1;
print_char s.[!i];
i := !i + 1
done
}
rule main = parse
"`" { command_beginning := Lexing.lexeme_start lexbuf;
first_item := true;
print_char '(';
command lexbuf;
print_char ')';
main lexbuf }
| "\\`"
{ print_string "`"; main lexbuf }
| eof { () }
| _ { print_char(Lexing.lexeme_char lexbuf 0); main lexbuf }
and command = parse
"`" { () }
| eof { prerr_string "Unterminated `...` at character ";
prerr_int !command_beginning;
prerr_newline();
exit 2 }
| "{" [^ '}'] * "}"
{ let s = Lexing.lexeme lexbuf in
add_semicolon();
print_string (String.sub s 1 (String.length s - 2));
command lexbuf }
| ( [^ '`' '{' '\\'] |
'\\' ['\\' '"' 'n' 't' 'b' 'r' '`' '{' ] |
'\\' ['0'-'9'] ['0'-'9'] ['0'-'9'] ) +
{ let s = Lexing.lexeme lexbuf in
add_semicolon();
(* Optimise one-character strings *)
if String.length s = 1 && s.[0] <> '\\' && s.[0] <> '\''
|| String.length s = 2 && s.[0] = '\\' && s.[1] <> '`' && s.[1]<>'{'
(* ` *)
then begin
print_string "emit_char '";
print_unescaped_string s;
print_string "'"
end else begin
print_string "emit_string \"";
print_unescaped_string s;
print_string "\""
end;
command lexbuf }
{
let _ = main(Lexing.from_channel stdin)
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...