src/Pure/Isar/outer_syntax.ML
changeset 23796 f37ff1f39fe9
parent 23722 a4af559708ab
child 23866 5295671034f8
equal deleted inserted replaced
23795:b094f9b7a52d 23796:f37ff1f39fe9
    25 sig
    25 sig
    26   include BASIC_OUTER_SYNTAX
    26   include BASIC_OUTER_SYNTAX
    27   type token
    27   type token
    28   type parser
    28   type parser
    29   val get_lexicons: unit -> Scan.lexicon * Scan.lexicon
    29   val get_lexicons: unit -> Scan.lexicon * Scan.lexicon
       
    30   val command_keyword: string -> OuterKeyword.T option
    30   val command: string -> string -> OuterKeyword.T ->
    31   val command: string -> string -> OuterKeyword.T ->
    31     (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
    32     (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
    32   val markup_command: ThyOutput.markup -> string -> string -> OuterKeyword.T ->
    33   val markup_command: ThyOutput.markup -> string -> string -> OuterKeyword.T ->
    33     (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
    34     (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
    34   val improper_command: string -> string -> OuterKeyword.T ->
    35   val improper_command: string -> string -> OuterKeyword.T ->
   131 
   132 
   132 fun get_lexicons () = ! global_lexicons;
   133 fun get_lexicons () = ! global_lexicons;
   133 fun get_parsers () = ! global_parsers;
   134 fun get_parsers () = ! global_parsers;
   134 fun get_parser () = Option.map (#2 o #1) o Symtab.lookup (get_parsers ());
   135 fun get_parser () = Option.map (#2 o #1) o Symtab.lookup (get_parsers ());
   135 
   136 
   136 fun command_tags name =
   137 fun command_keyword name =
   137   (case Symtab.lookup (get_parsers ()) name of
   138   Option.map (fn (((_, k), _), _) => k) (Symtab.lookup (get_parsers ()) name);
   138     SOME (((_, k), _), _) => OuterKeyword.tags_of k
   139 fun command_tags name = these ((Option.map OuterKeyword.tags_of) (command_keyword name));
   139   | NONE => []);
       
   140 
   140 
   141 fun is_markup kind name = (AList.lookup (op =) (! global_markups) name = SOME kind);
   141 fun is_markup kind name = (AList.lookup (op =) (! global_markups) name = SOME kind);
   142 
   142 
   143 
   143 
   144 (* augment syntax *)
   144 (* augment syntax *)
   247 
   247 
   248 fun deps_thy name ml path =
   248 fun deps_thy name ml path =
   249   let
   249   let
   250     val src = Source.of_string (File.read path);
   250     val src = Source.of_string (File.read path);
   251     val pos = Position.path path;
   251     val pos = Position.path path;
   252     val (name', parents, files) = ThyHeader.read (src, pos);
   252     val (name', imports, uses) = ThyHeader.read (src, pos);
   253     val ml_path = ThyLoad.ml_path name;
   253     val ml_path = ThyLoad.ml_path name;
   254     val ml_file = if ml andalso is_some (ThyLoad.check_file NONE ml_path) then [ml_path] else [];
   254     val ml_file = if ml andalso is_some (ThyLoad.check_file NONE ml_path) then [ml_path] else [];
   255   in
   255   in
   256     if name <> name' then
   256     if name <> name' then
   257       error ("Filename " ^ quote (Path.implode path) ^
   257       error ("Filename " ^ quote (Path.implode path) ^
   258         " does not agree with theory name " ^ quote name')
   258         " does not agree with theory name " ^ quote name')
   259     else (parents, map (Path.explode o #1) files @ ml_file)
   259     else (imports, map (Path.explode o #1) uses @ ml_file)
   260   end;
   260   end;
   261 
   261 
   262 
   262 
   263 (* load_thy *)
   263 (* load_thy *)
   264 
   264