(* runvhc.ml, Objective Caml version 3.08.1 *) open Aintv;; open Printer;; open Lexervhc;; open Lexing;; open Parse_exceptions;; open Parservhc;; let executer lexbuf = try let p = (program token lexbuf) in print_string "--" ; print_newline () ; print_prog p ; print_string "--" ; print_newline () ; evalprog p with | Undefined_variable (s, i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nVariable non définie : "; print_string s; print_newline () ) | Variable_in_body (s,i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nVariable dans le corps du programme : "; print_string s; print_newline () ) | Undefined_function (s,i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nFonction non définie : "; print_string s; print_newline () ) | Function_call_mismatch (s,i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nLe nombre de paramètres ne concorde pas : "; print_string s; print_newline () ) | Double_fundef (s,i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nDoublon définition de fonction : "; print_string s; print_newline () ) | Double_argdef (s,i) -> (print_string "Entrée interactive, caractère : "; print_int (i + 1); print_string "\nDoublon définition de paramètre formel : "; print_string s; print_newline () ) | Eof -> (print_string "Fin de fichier.\n" ; exit 0) | e -> print_string (Printexc.to_string e) let boucle_interactive _ = while true do let lexbuf = (print_string ">"; flush stdout; Lexing.from_channel stdin) in executer lexbuf done let executer_fichier fichier = executer (Lexing.from_channel (open_in fichier)) let run () = Random.self_init (); print_string "CAMLote 1.0"; print_newline (); if Array.length Sys.argv <= 1 then boucle_interactive () else Arg.parse [ "-t", Arg.Unit trace_eval, ": trace à l'exécution"; "--trace", Arg.Unit trace_eval, ": trace à l'exécution"; "-u", Arg.Unit trace_eval, ": désactiver la trace à l'exécution"; "--untrace", Arg.Unit untrace_eval, " : désactiver la trace à l'exécution"; "--", Arg.String executer_fichier, "fichier : exécuter un fichier dont le nom commence par -"; ] executer_fichier ("Usage : " ^ Sys.executable_name ^ " [options] [[ -- ] fichiers] Les options et fichiers peuvent être spécifiés dans n'importe quel ordre. Par exemple, la commande : " ^ Sys.executable_name ^ " -t fichier1 fichier2 -u fichier3 fichier4 exécute fichier1 et fichier2 avec la trace d'exécution, et fichier3 et fichier4 sans la trace d'exécution. ") ;; run ();; (* exception Undefined_variable of (string * int) exception Variable_in_body of (string * int) exception Undefined_function of (string * int) exception Function_call_mismatch of (string * int) exception Double_fundef of (string * int) exception Double_argdef of (string * int) *)