];
include_command: [ [
- IDENT "include" ; path = QSTRING -> loc,path
+ IDENT "include" ; path = QSTRING ->
+ loc,path,LexiconAst.WithPreferences
+ | IDENT "include'" ; path = QSTRING ->
+ loc,path,LexiconAst.WithoutPreferences
]];
grafite_command: [ [
fun ~include_paths status -> status,LSome(GrafiteAst.Executable (loc,ex))
| com = comment ->
fun ~include_paths status -> status,LSome (GrafiteAst.Comment (loc, com))
- | (iloc,fname) = include_command ; SYMBOL "." ->
+ | (iloc,fname,mode) = include_command ; SYMBOL "." ->
fun ~include_paths status ->
let path = DependenciesParser.baseuri_of_script ~include_paths fname in
let status =
- LexiconEngine.eval_command status (LexiconAst.Include (iloc,path))
+ LexiconEngine.eval_command status (LexiconAst.Include (iloc,path,mode))
in
status,
LSome
else
status
-let set_proof_aliases status new_aliases =
- let commands_of_aliases =
- List.map
- (fun alias -> LexiconAst.Alias (HExtlib.dummy_floc, alias))
- in
- let deps_of_aliases =
- HExtlib.filter_map
- (function
- | LexiconAst.Ident_alias (_, suri) ->
- let buri = UriManager.buri_of_uri (UriManager.uri_of_string suri) in
- Some (LibraryNoDb.Dependency buri)
- | _ -> None)
- in
- let aliases =
- List.fold_left (fun acc (d,c) -> DisambiguateTypes.Environment.add d c acc)
- status.aliases new_aliases in
- let multi_aliases =
- List.fold_left (fun acc (d,c) -> DisambiguateTypes.Environment.cons d c acc)
- status.multi_aliases new_aliases in
- let new_status =
- { status with multi_aliases = multi_aliases ; aliases = aliases}
- in
- if new_aliases = [] then
- new_status
+let set_proof_aliases mode status new_aliases =
+ if mode = LexiconAst.WithoutPreferences then
+ status
else
- let aliases =
- DisambiguatePp.aliases_of_domain_and_codomain_items_list new_aliases
+ let commands_of_aliases =
+ List.map
+ (fun alias -> LexiconAst.Alias (HExtlib.dummy_floc, alias))
in
- let status = add_lexicon_content (commands_of_aliases aliases) new_status in
- let status = add_metadata (deps_of_aliases aliases) status in
- status
+ let deps_of_aliases =
+ HExtlib.filter_map
+ (function
+ | LexiconAst.Ident_alias (_, suri) ->
+ let buri = UriManager.buri_of_uri (UriManager.uri_of_string suri) in
+ Some (LibraryNoDb.Dependency buri)
+ | _ -> None)
+ in
+ let aliases =
+ List.fold_left (fun acc (d,c) -> DisambiguateTypes.Environment.add d c acc)
+ status.aliases new_aliases in
+ let multi_aliases =
+ List.fold_left (fun acc (d,c) -> DisambiguateTypes.Environment.cons d c acc)
+ status.multi_aliases new_aliases in
+ let new_status =
+ { status with multi_aliases = multi_aliases ; aliases = aliases}
+ in
+ if new_aliases = [] then
+ new_status
+ else
+ let aliases =
+ DisambiguatePp.aliases_of_domain_and_codomain_items_list new_aliases
+ in
+ let status =
+ add_lexicon_content (commands_of_aliases aliases) new_status
+ in
+ let status = add_metadata (deps_of_aliases aliases) status in
+ status
+
-let rec eval_command status cmd =
+let rec eval_command ?(mode=LexiconAst.WithPreferences) status cmd =
let notation_ids' = CicNotation.process_notation cmd in
let status =
{ status with notation_ids = notation_ids' @ status.notation_ids } in
match cmd with
- | LexiconAst.Include (loc, baseuri) ->
+ | LexiconAst.Include (loc, baseuri, mode) ->
let lexiconpath_rw, lexiconpath_r =
LibraryMisc.lexicon_file_of_baseuri
~must_exist:false ~writable:true ~baseuri,
raise (IncludedFileNotCompiled lexiconpath_rw)
in
let lexicon = LexiconMarshal.load_lexicon lexiconpath in
- let status = List.fold_left eval_command status lexicon in
+ let status = List.fold_left (eval_command ~mode) status lexicon in
if Helm_registry.get_bool "db.nodb" then
let metadatapath_rw, metadatapath_r =
LibraryMisc.metadata_file_of_baseuri
[DisambiguateTypes.Num instance,
DisambiguateChoices.lookup_num_by_dsc desc]
in
- set_proof_aliases status diff
+ set_proof_aliases mode status diff
| LexiconAst.Interpretation (_, dsc, (symbol, _), cic_appl_pattern) as stm ->
let status = add_lexicon_content [stm] status in
let uris =
[DisambiguateTypes.Symbol (symbol, 0),
DisambiguateChoices.lookup_symbol_by_dsc symbol dsc]
in
- let status = set_proof_aliases status diff in
+ let status = set_proof_aliases mode status diff in
let status = add_metadata uris status in
status
| LexiconAst.Notation _ as stm -> add_lexicon_content [stm] status
+let eval_command = eval_command ?mode:None
+
+let set_proof_aliases = set_proof_aliases LexiconAst.WithPreferences
+