~ubuntu-branches/ubuntu/karmic/ocaml-doc/karmic

« back to all changes in this revision

Viewing changes to examples/picomach/asm.ml

  • Committer: Bazaar Package Importer
  • Author(s): Vanicat Rémi
  • Date: 2002-02-05 10:51:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020205105143-a061tunf8tev07ne
Tags: 3.04-4
* New debian maintainer
* Split doc-base file
* Move to non-free
* Change the copyright file to the copyright of the documentation
* remove FAQs (their license prohibit their redistribution)
* corrected the examples

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
let assemble_fichier nom_entr�e nom_sortie =
 
2
    let entr�e = open_in nom_entr�e in
 
3
    let sortie = open_out_bin nom_sortie in
 
4
      try
 
5
        output_value sortie
 
6
          (Lecture.programme (Stream.of_channel entr�e));
 
7
        close_in entr�e;
 
8
        close_out sortie;
 
9
        0
 
10
      with exc ->
 
11
        close_in entr�e;
 
12
        close_out sortie;
 
13
        Sys.remove nom_sortie;
 
14
        match exc with
 
15
        | Stream.Error _ ->
 
16
            prerr_string
 
17
              "Erreur de syntaxe aux alentours du caract�re num�ro ";
 
18
            prerr_int (pos_in entr�e);
 
19
            prerr_endline "";
 
20
            1
 
21
        | Stockage.Erreur message ->
 
22
            prerr_string "Erreur d'assemblage: ";
 
23
            prerr_endline message;
 
24
            1
 
25
        | _ ->
 
26
            raise exc;;
 
27
 
 
28
exception Mauvais_arguments;;
 
29
 
 
30
if !Sys.interactive then () else
 
31
try
 
32
  if Array.length Sys.argv <> 3 then raise Mauvais_arguments;
 
33
  exit (assemble_fichier Sys.argv.(1) Sys.argv.(2))
 
34
with
 
35
| Mauvais_arguments ->
 
36
    prerr_endline
 
37
      "Usage: pico_asm <fichier assembleur> <fichier de code>";
 
38
    exit 2
 
39
| Sys_error message ->
 
40
    prerr_string "Erreur du syst�me: "; prerr_endline message;
 
41
    exit 2;;