]> matita.cs.unibo.it Git - helm.git/commitdiff
eval_from_stream is now tail recursive!
authorEnrico Tassi <enrico.tassi@inria.fr>
Fri, 6 Apr 2007 11:25:34 +0000 (11:25 +0000)
committerEnrico Tassi <enrico.tassi@inria.fr>
Fri, 6 Apr 2007 11:25:34 +0000 (11:25 +0000)
helm/software/matita/matitaEngine.ml

index 191c60bb170356a6a7cceb486c84f4171f6d70e1..133893f0d1e8cf77155f33de2b3d1fa6a0f4db47 100644 (file)
@@ -116,10 +116,15 @@ let eval_from_stream ~first_statement_only ~include_paths ?(prompt=false)
     loop
   in
    if prompt then (print_string "matita> "; flush stdout);
-   try
-    let lexicon_status,ast =
-     GrafiteParser.parse_statement ~include_paths str lexicon_status
-    in
+   let cont =
+     try
+       Some (GrafiteParser.parse_statement ~include_paths str lexicon_status)
+     with
+       End_of_file -> None
+   in
+   match cont with
+   | None -> statuses
+   | Some (lexicon_status,ast) ->
      (match ast with
          GrafiteParser.LNone _ ->
           watch_statuses lexicon_status grafite_status ;
@@ -150,8 +155,6 @@ let eval_from_stream ~first_statement_only ~include_paths ?(prompt=false)
           in
            watch_statuses lexicon_status grafite_status ;
            loop lexicon_status grafite_status (new_statuses @ statuses))
-   with
-    End_of_file -> statuses
  in
   loop lexicon_status grafite_status []
 ;;