~ubuntu-branches/ubuntu/hardy/ocaml-doc/hardy

« back to all changes in this revision

Viewing changes to examples/pascal/ipascal.ml

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2007-09-08 01:49:22 UTC
  • mfrom: (0.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070908014922-lvihyehz0ndq7suu
Tags: 3.10-1
* New upstream release.
* Removed camlp4 documentation since it is not up-to-date.
* Updated to standards version 3.7.2, no changes needed.
* Updated my email address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
(***********************************************************************)
2
 
(*                                                                     *)
3
 
(*                           Objective Caml                            *)
4
 
(*                                                                     *)
5
 
(*               Pierre Weis, projet Cristal, INRIA Rocquencourt       *)
6
 
(*                                                                     *)
7
 
(*  Copyright 2001 Institut National de Recherche en Informatique et   *)
8
 
(*  en Automatique.  All rights reserved.  This file is distributed    *)
9
 
(*  only by permission.                                                *)
10
 
(*                                                                     *)
11
 
(***********************************************************************)
12
 
open Syntaxe;;
13
 
 
14
 
let interpr�te_fichier nom =
15
 
  try
16
 
    let canal = open_in nom in
17
 
    try
18
 
      let prog = lire_programme (Stream.of_channel canal) in
19
 
      close_in canal;
20
 
      Typage.type_programme prog;                 (* ligne ajout�e *)
21
 
      Interp.ex�cute_programme prog
22
 
    with
23
 
    | Stream.Error s ->
24
 
        prerr_string
25
 
          ("Erreur de syntaxe : " ^ s ^ " aux alentours du caract�re num�ro ");
26
 
        prerr_int (pos_in canal);
27
 
        prerr_endline ""
28
 
    | Typage.Erreur_typage err ->
29
 
        Typage.affiche_erreur err;
30
 
        exit 2
31
 
    | Valeur.Erreur_ex�cution message ->
32
 
        prerr_string "Erreur pendant l'ex�cution: ";
33
 
        prerr_endline message
34
 
  with
35
 
  | Sys_error message ->
36
 
      prerr_string "Erreur du syst�me: ";
37
 
      prerr_endline message
38
 
  | Stream.Failure -> ();;
39
 
 
40
 
if not !Sys.interactive
41
 
  then begin interpr�te_fichier Sys.argv.(1); exit 0 end;;
42
 
 
43
 
 
44
 
 
45
 
 
46
 
 
47
 
 
48