From e1fb5311d4ea71e7cdf7d042b7afe30d0ec6edd8 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 6 Apr 2007 11:25:34 +0000 Subject: [PATCH] eval_from_stream is now tail recursive! --- matita/matitaEngine.ml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/matita/matitaEngine.ml b/matita/matitaEngine.ml index 191c60bb1..133893f0d 100644 --- a/matita/matitaEngine.ml +++ b/matita/matitaEngine.ml @@ -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 [] ;; -- 2.39.2