/[geocaml]/geocaml/src/main.ml
ViewVC logotype

Diff of /geocaml/src/main.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gmariano, Thu Mar 27 09:01:00 2003 UTC revision 1.4 by adoniec, Mon Mar 31 07:40:30 2003 UTC
# Line 1  Line 1 
 (* $Id$ *)  
1    
2  type to_do = LATEX | PS | XML | DRAWING | EMPTY  type to_do = LATEX | PS | XML | DRAWING | EMPTY
3    
4  type to_open = SOURCE  type to_open = SOURCE | INTERACTIVE_MODE
5    
6  let toopen = ref SOURCE  let toopen = ref INTERACTIVE_MODE
7    
8  let todo = ref EMPTY  let todo = ref EMPTY
9    
# Line 16  let ywin = ref 480 Line 15  let ywin = ref 480
15    
16  let wait() = let _ = input_char stdin in ()  let wait() = let _ = input_char stdin in ()
17    
18  let analyse s =  let draw () =
19      let f = new Drawing.figure (!xwin,!ywin) in
20      Geom.draw_figure Geom.my_figure f;
21      while true do f#action() done
22    
23    let draw2 () =
24      let f = new Drawing.figure (!xwin,!ywin) in
25      Geom.draw_figure Geom.my_figure f;
26      f
27    
28    let redraw f =
29      begin
30        f#purge;
31        f#redraw();
32        Geom.draw_figure Geom.my_figure f
33      end      
34    
35    let analyse_file s =
36    let ch_in = open_in s in    let ch_in = open_in s in
37    (try    (try
38      let lexbuf = Lexing.from_channel ch_in in      let lexbuf = Lexing.from_channel ch_in in
39      while true do      while true do
40        let result = Parser.declaration Lexer.token lexbuf in        let result = Parser.start Lexer.token lexbuf in
41        Abrlex.add_abr result Geom.my_figure;flush stdout        Abrlex.add_abr result Geom.my_figure;flush stdout
42      done      done
43    with Lexer.Eof -> (print_string "Parsing ok...\n";flush stdout))    with Lexer.Eof -> (print_string "Parsing ok...\n";flush stdout))
44    
45  let draw () =  let print_mess_error type_of_mess mess =
46    let f = new Drawing.figure (!xwin,!ywin) in    begin
47    Geom.draw_figure Geom.my_figure f;      print_string ("\t% "^type_of_mess^":\n");
48    while true do f#action() done      print_string ("\t% "^mess^"\n")
49      end
50    
51    let rec analyse_stdin f =
52      try
53        let lexbuf = Lexing.from_channel stdin in
54          while true do
55            let result = Parser.start Lexer.token lexbuf in
56              begin
57                Abrlex.add_abr result Geom.my_figure f;
58                redraw f;
59                flush stdout;
60                print_string "# ";
61                flush stdout
62              end
63          done
64      with Lexer.Eof -> (print_string "Bye...\n";flush stdout)
65        | Parsing.Parse_error -> (print_mess_error "Syntaxe incorrecte!" "Voir manuel";flush stdout;analyse_stdin f)
66        | e -> (print_mess_error "Erreur !" (Abrlex.treat_exception e);flush stdout;analyse_stdin f)
67    
68    
69  let make_postcript () =  let make_postcript () =
70    let channel = open_out ((!sources)^".xml") in    let channel = open_out ((!sources)^".xml") in
# Line 60  let options_list = Line 95  let options_list =
95    
96  let use_message = "Usage : "^Sys.argv.(0)^"[options] fichier source"  let use_message = "Usage : "^Sys.argv.(0)^"[options] fichier source"
97    
98  let treat_end s = (sources := s)  let treat_end s =
99      begin
100        toopen := SOURCE;
101        sources := s
102      end
103    
104  let main() =  let main() =
105    if !Sys.interactive then () else    if !Sys.interactive then () else
106    begin    begin
107      Random.self_init();      Random.self_init();
     print_string ("GeOCaml v0.0.1\n");  
108      Arg.parse options_list treat_end use_message;      Arg.parse options_list treat_end use_message;
109      (match !toopen with      (match !toopen with
110      | SOURCE -> analyse !sources      | SOURCE ->
111            begin
112              print_string ("GeOCaml v0.0.1\n");
113              flush stdout;
114              analyse_file !sources
115            end
116        | INTERACTIVE_MODE ->
117            begin
118              print_string "\t GeOCaml Interactive Mode\n\n";
119              print_string "# ";
120              flush stdout;
121              let f = draw2 () in
122                analyse_stdin f
123            end
124      );      );
125      match !todo with      match !todo with
126      | DRAWING -> draw ()      | DRAWING -> draw ()
# Line 82  let main() = Line 133  let main() =
133  let _ = Printexc.catch main()  let _ = Printexc.catch main()
134    
135  ;;  ;;
136    
137    
138    
139    
140    
141    
142    
143    
144    
145    
146    
147    
148    
149    
150    
151    
152    
153    
154    
155    
156    
157    
158    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26