]> matita.cs.unibo.it Git - helm.git/blobdiff - components/grafite_parser/dependenciesParser.ml
beginning to see the light
[helm.git] / components / grafite_parser / dependenciesParser.ml
index 2f7c5ec0cffbfdd2138bba285c6bfa3646ca896a..32ee44491020b96d3108199858b2a7fe0e8d3c2e 100644 (file)
@@ -41,26 +41,29 @@ let parse_dependencies lexbuf =
     CicNotationLexer.level2_ast_lexer.Token.tok_func (Obj.magic lexbuf)
   in
   let rec parse acc = 
-   try
-    (parser
-    | [< '("QSTRING", s) >] ->
-        (* because of alias id qstring = qstring :-( *)
-        (try
-          parse (UriDep (UriManager.uri_of_string s) :: acc)
-         with
-          UriManager.IllFormedUri _ -> parse acc)
-    | [< '("URI", u) >] ->
-        parse (UriDep (UriManager.uri_of_string u) :: acc)
-    | [< '("IDENT", "include"); '("QSTRING", fname) >] ->
-        parse (IncludeDep fname :: acc)
-    | [< '("IDENT", "include'"); '("QSTRING", fname) >] ->
-        parse (IncludeDep fname :: acc)
-    | [< '("EOI", _) >] -> acc
-    | [< 'tok >] -> parse acc
-    | [<  >] -> acc) tok_stream
-   with
-      Stream.Error _ -> parse acc
-    | CicNotationLexer.Error _ -> parse acc
+   let continue, acc =
+     try
+      (parser
+      | [< '("QSTRING", s) >] ->
+          (* because of alias id qstring = qstring :-( *)
+          (try
+            true, (UriDep (UriManager.uri_of_string s) :: acc)
+           with
+            UriManager.IllFormedUri _ -> true, acc)
+      | [< '("URI", u) >] ->
+          true, (UriDep (UriManager.uri_of_string u) :: acc)
+      | [< '("IDENT", "include"); '("QSTRING", fname) >] ->
+          true, (IncludeDep fname :: acc)
+      | [< '("IDENT", "include'"); '("QSTRING", fname) >] ->
+          true, (IncludeDep fname :: acc)
+      | [< '("EOI", _) >] -> false, acc
+      | [< 'tok >] -> true, acc
+      | [<  >] -> false, acc) tok_stream
+     with
+        Stream.Error _ -> false, acc
+      | CicNotationLexer.Error _ -> true, acc
+   in
+    if continue then parse acc else acc
   in
   List.rev (parse [])