]> matita.cs.unibo.it Git - helm.git/blobdiff - components/grafite_parser/grafiteParser.ml
snopshot (working one!)
[helm.git] / components / grafite_parser / grafiteParser.ml
index c948272ef40ff913d6817275fbfdc4d4b10df460..df18135ac56370767d77c3896855f2f3c62fbba8 100644 (file)
@@ -30,6 +30,8 @@ let set_callback f = out := f
 
 module Ast = CicNotationPt
 
+exception NoInclusionPerformed of string (* full path *)
+
 type 'a localized_option =
    LSome of 'a
  | LNone of GrafiteAst.loc
@@ -41,6 +43,7 @@ type ast_statement =
     GrafiteAst.statement
 
 type statement =
+  ?never_include:bool -> 
   include_paths:string list ->
   LexiconEngine.status ->
     LexiconEngine.status * ast_statement localized_option
@@ -687,17 +690,18 @@ EXTEND
   ];
   statement: [
     [ ex = executable ->
-       fun ~include_paths status -> status,LSome(GrafiteAst.Executable (loc,ex))
+       fun ?(never_include=false) ~include_paths status -> status,LSome(GrafiteAst.Executable (loc,ex))
     | com = comment ->
-       fun ~include_paths status -> status,LSome (GrafiteAst.Comment (loc, com))
+       fun ?(never_include=false) ~include_paths status -> status,LSome (GrafiteAst.Comment (loc, com))
     | (iloc,fname,mode) = include_command ; SYMBOL "."  ->
-       fun ~include_paths status ->
+       fun ?(never_include=false) ~include_paths status ->
        let _root, buri, fullpath, _rrelpath = 
           Librarian.baseuri_of_script ~include_paths fname 
         in
         let status =
-         LexiconEngine.eval_command status 
-           (LexiconAst.Include (iloc,buri,mode,fullpath))
+         if never_include then raise (NoInclusionPerformed fullpath)
+         else LexiconEngine.eval_command status 
+                (LexiconAst.Include (iloc,buri,mode,fullpath))
         in
         !out fname;
          status,
@@ -706,7 +710,7 @@ EXTEND
            (loc,GrafiteAst.Command
             (loc,GrafiteAst.Include (iloc,buri))))
     | scom = lexicon_command ; SYMBOL "." ->
-       fun ~include_paths status ->
+       fun ?(never_include=false) ~include_paths status ->
        let status = LexiconEngine.eval_command status scom in
          status,LNone loc
     | EOI -> raise End_of_file