acg.ml 2.65 KB
Newer Older
1 2 3 4 5 6
(**************************************************************************)
(*                                                                        *)
(*                 ACG development toolkit                                *)
(*                                                                        *)
(*                  Copyright 2008 INRIA                                  *)
(*                                                                        *)
7
(*  More information on "http://acg.gforge.inria.fr/"                     *)
8 9 10 11 12 13 14 15 16 17 18 19
(*  License: CeCILL, see the LICENSE file or "http://www.cecill.info"     *)
(*  Authors: see the AUTHORS file                                         *)
(*                                                                        *)
(*                                                                        *)
(*                                                                        *)
(*                                                                        *)
(*  $Rev::                              $:  Revision of last commit       *)
(*  $Author::                           $:  Author of last commit         *)
(*  $Date::                             $:  Date of last commit           *)
(*                                                                        *)
(**************************************************************************)

20 21
open Functions

POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
22 23
let () = Sys.catch_break true

24 25 26 27 28 29

let dirs = ref [""]


let options =
  [
30
    ("-version", Arg.Unit (fun () -> Printf.printf "%s\n" Version.version;exit 0), " Prints the version number");
31 32 33 34 35 36
    ("-I", Arg.String (fun dir -> dirs := (!dirs)@[dir]) , " -I dir sets dir as a directory in which file arguments can be looked for")
  ]

let usg_msg = Printf.sprintf "%s [options] file1 file2 ...\n\nThis will parse the files which are supposed to be files acripting commands and then run the ACG command interpreter." Sys.executable_name


37
module Lex = Acg_lexicon.Sylvain_lexicon
38 39 40
  
module E = Environment.Make(Lex)

POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
41
module P = Script_parser.Make(E)
42

POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
43

POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
44 45

let welcome_msg = 
46 47 48
  Printf.sprintf
    "\n\t\t\tWelcome to the ACG toplevel\n\t\t\t    Version %s\n\t\t\t\tINRIA 2008\nPlease send your comments or bug reports or featrure requests to sylvain.pogodalla@loria.fr\n\n\nType\n\t\thelp ;\nto get help.\n\n\n\n"
    Version.version
49 50 51 52


let env = ref E.empty

53
let anon_fun s = env := P.parse_file  s !dirs !env
54 55
  
let _ =
56
  let () = Arg.parse options anon_fun usg_msg in
POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
57
  let () = Printf.printf "%s%!" welcome_msg in
58
  let continue = ref true in
POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
59
  let () = 
60 61
    while !continue do
      try
62
	env := P.parse_entry !dirs !env
63
      with
POGODALLA Sylvain's avatar
POGODALLA Sylvain committed
64 65 66 67
	| End_of_file
	| Sys.Break -> continue := false
    done in
    Printf.printf "\n%!"
68