src/Pure/Isar/outer_syntax.ML
author wenzelm
Thu, 22 Jul 1999 20:53:26 +0200
changeset 7062 e992884b256d
parent 7026 69724548fad1
child 7104 247e4247b64e
permissions -rw-r--r--
Toplevel.excursion_error;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/outer_syntax.ML
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     4
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     5
The global Isabelle/Isar outer syntax.
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     6
*)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     7
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     8
signature BASIC_OUTER_SYNTAX =
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
     9
sig
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    10
  val main: unit -> unit
5883
975c984526b0 tuned names;
wenzelm
parents: 5829
diff changeset
    11
  val loop: unit -> unit
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
    12
  val sync_main: unit -> unit
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
    13
  val sync_loop: unit -> unit
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    14
  val help: unit -> unit
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    15
end;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    16
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    17
signature OUTER_SYNTAX =
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    18
sig
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    19
  include BASIC_OUTER_SYNTAX
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    20
  structure Keyword:
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    21
    sig
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    22
      val control: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    23
      val diag: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    24
      val thy_begin: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    25
      val thy_end: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    26
      val thy_heading: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    27
      val thy_decl: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    28
      val thy_goal: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    29
      val qed: string
6733
429bbd7ef26d qed_block keywords;
wenzelm
parents: 6722
diff changeset
    30
      val qed_block: string
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    31
      val prf_goal: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    32
      val prf_block: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    33
      val prf_chain: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    34
      val prf_decl: string
6868
27ba88d57399 added prf_asm;
wenzelm
parents: 6860
diff changeset
    35
      val prf_asm: string
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    36
      val prf_script: string
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    37
      val kinds: string list
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    38
    end
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    39
  type token
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    40
  type parser
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    41
  val command: string -> string -> string ->
6373
47b357194f32 added (improper_)command;
wenzelm
parents: 6332
diff changeset
    42
    (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    43
  val improper_command: string -> string -> string ->
6373
47b357194f32 added (improper_)command;
wenzelm
parents: 6332
diff changeset
    44
    (token list -> (Toplevel.transition -> Toplevel.transition) * token list) -> parser
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
    45
  val dest_keywords: unit -> string list
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
    46
  val dest_parsers: unit -> (string * string * string * bool) list
5883
975c984526b0 tuned names;
wenzelm
parents: 5829
diff changeset
    47
  val print_outer_syntax: unit -> unit
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    48
  val add_keywords: string list -> unit
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    49
  val add_parsers: parser list -> unit
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
    50
  val theory_header: token list -> (string * string list * (string * bool) list) * token list
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
    51
  val deps_thy: string -> bool -> Path.T -> string list * Path.T list
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
    52
  val load_thy: string -> bool -> bool -> Path.T -> unit
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
    53
  val isar: bool -> Toplevel.isar
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    54
end;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    55
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    56
structure OuterSyntax: OUTER_SYNTAX =
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    57
struct
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    58
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
    59
structure P = OuterParse;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
    60
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    61
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    62
(** outer syntax **)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    63
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    64
(* command keyword classification *)
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    65
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    66
structure Keyword =
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    67
struct
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    68
  val control = "control";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    69
  val diag = "diag";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    70
  val thy_begin = "theory-begin";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    71
  val thy_end = "theory-end";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    72
  val thy_heading = "theory-heading";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    73
  val thy_decl = "theory-decl";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    74
  val thy_goal = "theory-goal";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    75
  val qed = "qed";
6733
429bbd7ef26d qed_block keywords;
wenzelm
parents: 6722
diff changeset
    76
  val qed_block = "qed-block";
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    77
  val prf_goal = "proof-goal";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    78
  val prf_block = "proof-block";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    79
  val prf_chain = "proof-chain";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    80
  val prf_decl = "proof-decl";
6868
27ba88d57399 added prf_asm;
wenzelm
parents: 6860
diff changeset
    81
  val prf_asm = "proof-asm";
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    82
  val prf_script = "proof-script";
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    83
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    84
  val kinds = [control, diag, thy_begin, thy_end, thy_heading, thy_decl, thy_goal, qed,
6868
27ba88d57399 added prf_asm;
wenzelm
parents: 6860
diff changeset
    85
    qed_block, prf_goal, prf_block, prf_chain, prf_decl, prf_asm, prf_script];
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    86
end;
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    87
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    88
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    89
(* parsers *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    90
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    91
type token = OuterLex.token;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    92
type parser_fn = token list -> (Toplevel.transition -> Toplevel.transition) * token list;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    93
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    94
datatype parser =
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    95
  Parser of string * (string * string) * bool * parser_fn;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    96
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
    97
fun parser int_only name comment kind parse = Parser (name, (comment, kind), int_only, parse);
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    98
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
    99
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   100
(* parse command *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   101
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   102
local
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   103
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   104
fun command_body cmd (name, _) =
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   105
  (case cmd name of
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   106
    Some (int_only, parse) => P.!!! (Scan.prompt (name ^ "# ") (parse >> pair int_only))
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   107
  | None => sys_error ("no parser for outer syntax command " ^ quote name));
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   108
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   109
fun terminator false = Scan.succeed ()
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   110
  | terminator true = P.group "terminator" (Scan.option P.sync -- P.$$$ ";" >> K ());
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   111
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   112
in
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   113
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   114
fun command term cmd =
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   115
  P.$$$ ";" >> K None ||
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   116
  P.sync >> K None ||
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   117
  (P.position P.command :-- command_body cmd) --| terminator term
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   118
    >> (fn ((name, pos), (int_only, f)) =>
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   119
      Some (Toplevel.empty |> Toplevel.name name |> Toplevel.position pos |>
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   120
        Toplevel.interactive int_only |> f));
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   121
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   122
end;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   123
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   124
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   125
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   126
(** global syntax state **)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   127
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   128
local
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   129
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   130
val global_lexicons = ref (Scan.empty_lexicon, Scan.empty_lexicon);
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
   131
val global_parsers = ref (Symtab.empty: ((string * string) * (bool * parser_fn)) Symtab.table);
5952
7d4ec8992b23 added commands;
wenzelm
parents: 5923
diff changeset
   132
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   133
fun change_lexicons f =
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   134
  let val lexs = f (! global_lexicons) in
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   135
    (case (op inter_string) (pairself Scan.dest_lexicon lexs) of
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   136
      [] => global_lexicons := lexs
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   137
    | bads => error ("Clash of outer syntax commands and keywords: " ^ commas_quote bads))
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   138
  end;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   139
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   140
fun change_parsers f = global_parsers := f (! global_parsers);
6722
5e82c7196789 added keyword classification;
wenzelm
parents: 6685
diff changeset
   141
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   142
in
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   143
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   144
(* get current lexers / parsers *)
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   145
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   146
(*Note: the syntax for files is statically determined at the very
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   147
  beginning; for interactive processing it may change dynamically.*)
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   148
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   149
fun get_lexicons () = ! global_lexicons;
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   150
fun get_parsers () = ! global_parsers;
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   151
fun get_parser () = apsome snd o curry Symtab.lookup (! global_parsers);
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   152
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   153
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   154
(* augment syntax *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   155
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   156
fun add_keywords keywords = change_lexicons (apfst (fn lex =>
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   157
  (Scan.extend_lexicon lex (map Symbol.explode keywords))));
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   158
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   159
fun add_parser (tab, Parser (name, comment, int_only, parse)) =
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   160
 (if is_none (Symtab.lookup (tab, name)) then ()
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   161
  else warning ("Redefined outer syntax command " ^ quote name);
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   162
  Symtab.update ((name, (comment, (int_only, parse))), tab));
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   163
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   164
fun add_parsers parsers =
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   165
  (change_parsers (fn tab => foldl add_parser (tab, parsers));
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   166
    change_lexicons (apsnd (fn lex => Scan.extend_lexicon lex
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   167
      (map (fn Parser (name, _, _, _) => Symbol.explode name) parsers))));
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   168
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   169
end;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   170
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   171
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   172
(* print syntax *)
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   173
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   174
fun dest_keywords () = Scan.dest_lexicon (#1 (get_lexicons ()));
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   175
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   176
fun dest_parsers () =
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   177
  map (fn (name, ((cmt, kind), (int_only, _))) => (name, cmt, kind, int_only))
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   178
    (Symtab.dest (get_parsers ()));
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   179
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   180
fun print_outer_syntax () =
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   181
  let
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   182
    fun pretty_cmd (name, comment, _, _) =
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   183
      Pretty.block [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment];
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   184
    val (int_cmds, cmds) = partition #4 (dest_parsers ());
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   185
  in
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   186
    Pretty.writeln (Pretty.strs ("syntax keywords:" :: map quote (dest_keywords ())));
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   187
    Pretty.writeln (Pretty.big_list "proper commands:" (map pretty_cmd cmds));
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   188
    Pretty.writeln (Pretty.big_list "improper commands (interactive-only):"
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   189
      (map pretty_cmd int_cmds))
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   190
  end;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   191
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   192
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   193
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   194
(** read theory **)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   195
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   196
(* theory keyword *)
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   197
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   198
val theoryN = "theory";
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   199
val theory_keyword = OuterParse.$$$ theoryN;
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   200
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   201
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   202
(* source *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   203
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   204
local
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   205
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   206
val no_terminator =
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   207
  Scan.unless (P.$$$ ";") (Scan.one (OuterLex.not_sync andf OuterLex.not_eof));
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   208
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   209
val recover = Scan.prompt "recover# " (Scan.repeat no_terminator);
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   210
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   211
in
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   212
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   213
fun source term do_recover cmd src =
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   214
  src
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   215
  |> Source.source OuterLex.stopper
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   216
    (Scan.bulk (fn xs => OuterParse.!!! (command term (cmd ())) xs))
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   217
    (if do_recover then Some recover else None)
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   218
  |> Source.mapfilter I;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   219
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   220
end;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   221
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   222
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   223
(* detect header *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   224
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   225
fun scan_header get_lex scan (src, pos) =
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   226
  src
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   227
  |> Symbol.source false
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   228
  |> OuterLex.source false (fn () => (get_lex (), Scan.empty_lexicon)) pos
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   229
  |> Source.source OuterLex.stopper (Scan.single scan) None
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   230
  |> (fst o the o Source.get_single);
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   231
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   232
val check_header_lexicon = Scan.make_lexicon [Symbol.explode theoryN];
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   233
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   234
fun is_old_theory src =
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   235
  is_none (scan_header (K check_header_lexicon) (Scan.option theory_keyword) src);
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   236
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   237
fun warn_theory_style path is_old =
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   238
  let
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   239
    val style = if is_old then "old" else "new";
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   240
    val _ = warning ("Assuming " ^ style ^ "-style theory format for " ^ quote (Path.pack path));
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   241
  in is_old end;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   242
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   243
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   244
(* deps_thy --- inspect theory header *)
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   245
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   246
val header_lexicon =
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   247
  Scan.make_lexicon (map Symbol.explode ["(", ")", "+", ":", "=", "files", theoryN]);
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   248
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   249
local
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   250
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   251
val file_name =
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   252
  (P.$$$ "(" |-- P.!!! (P.name --| P.$$$ ")")) >> rpair false || P.name >> rpair true;
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   253
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   254
val theory_head =
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   255
  (P.name -- (P.$$$ "=" |-- P.enum1 "+" P.name) --
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   256
    Scan.optional (P.$$$ "files" |-- P.!!! (Scan.repeat1 file_name)) [])
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   257
  >> (fn ((A, Bs), files) => (A, Bs, files));
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   258
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   259
in
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   260
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   261
val theory_header = theory_head --| (Scan.ahead P.eof || P.$$$ ":");
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   262
val only_header = theory_keyword |-- theory_head --| Scan.ahead P.eof;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   263
val new_header = theory_keyword |-- P.!!! theory_header;
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   264
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   265
val old_header =
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   266
  P.name -- (P.$$$ "=" |-- P.name -- Scan.repeat (P.$$$ "+" |-- P.name))
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   267
  >> (fn (A, (B, Bs)) => (A, B :: Bs, []: (string * bool) list));
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   268
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   269
end;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   270
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   271
fun deps_thy name ml path =
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   272
  let
6641
254ab03bd082 rearranged some modules;
wenzelm
parents: 6373
diff changeset
   273
    val src = File.source path;
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   274
    val is_old = warn_theory_style path (is_old_theory src);
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   275
    val (name', parents, files) =
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   276
      (*Note: old style headers dynamically depend on the current lexicon :-( *)
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   277
      if is_old then scan_header ThySyn.get_lexicon (Scan.error old_header) src
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   278
      else scan_header (K header_lexicon) (Scan.error new_header) src;
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   279
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   280
    val ml_path = ThyLoad.ml_path name;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   281
    val ml_file = if not ml orelse is_none (ThyLoad.check_file ml_path) then [] else [ml_path];
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   282
  in
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   283
    if name <> name' then
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   284
      error ("Filename " ^ quote (Path.pack path) ^ " does not match theory name " ^ quote name)
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   285
    else (parents, map (Path.unpack o #1) files @ ml_file)
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   286
  end;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   287
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   288
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   289
(* load_thy --- read text (including header) *)
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   290
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   291
fun try_ml_file name ml time =
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   292
  let
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   293
    val path = ThyLoad.ml_path name;
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   294
    val tr = Toplevel.imperative (fn () => ThyInfo.load_file time path);
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   295
    val tr_name = if time then "time_use" else "use";
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   296
  in
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   297
    if not ml orelse is_none (ThyLoad.check_file path) then ()
7062
e992884b256d Toplevel.excursion_error;
wenzelm
parents: 7026
diff changeset
   298
    else Toplevel.excursion_error [Toplevel.empty |> Toplevel.name tr_name |> tr]
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   299
  end;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   300
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   301
fun parse_thy (src, pos) =
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   302
  let
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   303
    val lex_src =
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   304
      src
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   305
      |> Symbol.source false
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   306
      |> OuterLex.source false (K (get_lexicons ())) pos;
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   307
    val only_head =
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   308
      lex_src
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   309
      |> Source.source OuterLex.stopper (Scan.single (Scan.option only_header)) None
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   310
      |> (fst o the o Source.get_single);
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   311
  in
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   312
    (case only_head of
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   313
      None =>
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   314
        lex_src
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   315
        |> source false false (K (get_parser ()))
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   316
        |> Source.exhaust
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   317
    | Some spec =>
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   318
        [Toplevel.empty |> Toplevel.name theoryN |> IsarThy.theory spec,
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   319
          Toplevel.empty |> Toplevel.name "end" |> Toplevel.exit])
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   320
  end;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   321
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   322
fun run_thy name path =
6641
254ab03bd082 rearranged some modules;
wenzelm
parents: 6373
diff changeset
   323
  let val (src, pos) = File.source path in
6332
7cee353c7f2a Present.theory_source;
wenzelm
parents: 6247
diff changeset
   324
    Present.theory_source name src;
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   325
    if is_old_theory (src, pos) then ThySyn.load_thy name (Source.exhaust src)
7062
e992884b256d Toplevel.excursion_error;
wenzelm
parents: 7026
diff changeset
   326
    else Toplevel.excursion_error (parse_thy (src, pos))
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   327
  end;
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   328
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   329
fun load_thy name ml time path =
6247
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   330
 (if time then
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   331
    timeit (fn () =>
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   332
     (writeln ("\n**** Starting theory " ^ quote name ^ " ****");
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   333
      setmp Goals.proof_timing true (run_thy name) path;
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   334
      writeln ("**** Finished theory " ^ quote name ^ " ****\n")))
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   335
  else run_thy name path;
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   336
  Context.context (ThyInfo.get_theory name);
e8bbe64861b8 more robust handling of theory context;
wenzelm
parents: 6229
diff changeset
   337
  try_ml_file name ml time);
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   338
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   339
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   340
(* interactive source of state transformers *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   341
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   342
fun isar term =
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   343
  Source.tty
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   344
  |> Symbol.source true
7026
69724548fad1 separate command tokens;
wenzelm
parents: 6868
diff changeset
   345
  |> OuterLex.source true get_lexicons (Position.line_name 1 "stdin")
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   346
  |> source term true get_parser;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   347
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   348
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   349
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   350
(** the read-eval-print loop **)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   351
5923
wenzelm
parents: 5883
diff changeset
   352
(* main loop *)
wenzelm
parents: 5883
diff changeset
   353
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   354
fun gen_loop term = (Context.reset_context (); Toplevel.loop (isar term));
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   355
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   356
fun gen_main term =
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   357
 (Toplevel.set_state Toplevel.toplevel;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   358
  ml_prompts "ML> " "ML# ";
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   359
  writeln (Session.welcome ());
6860
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   360
  gen_loop term);
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   361
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   362
fun main () = gen_main false;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   363
fun loop () = gen_loop false;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   364
fun sync_main () = gen_main true;
8dc6a1e6fa13 added sync;
wenzelm
parents: 6733
diff changeset
   365
fun sync_loop () = gen_loop true;
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   366
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   367
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   368
(* help *)
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   369
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   370
fun help () =
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   371
  writeln ("This is Isabelle's underlying ML system (" ^ ml_system ^ ");\n\
5883
975c984526b0 tuned names;
wenzelm
parents: 5829
diff changeset
   372
    \invoke 'loop();' to enter the Isar loop.");
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   373
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   374
6373
47b357194f32 added (improper_)command;
wenzelm
parents: 6332
diff changeset
   375
(*final declarations of this structure!*)
6685
wenzelm
parents: 6641
diff changeset
   376
val command = parser false;
wenzelm
parents: 6641
diff changeset
   377
val improper_command = parser true;
wenzelm
parents: 6641
diff changeset
   378
6373
47b357194f32 added (improper_)command;
wenzelm
parents: 6332
diff changeset
   379
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   380
end;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   381
6199
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   382
(*setup theory syntax dependent operations*)
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   383
ThyLoad.deps_thy_fn := OuterSyntax.deps_thy;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   384
ThyLoad.load_thy_fn := OuterSyntax.load_thy;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   385
structure ThyLoad: THY_LOAD = ThyLoad;
9b1be867e21a removed load;
wenzelm
parents: 6107
diff changeset
   386
5829
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   387
structure BasicOuterSyntax: BASIC_OUTER_SYNTAX = OuterSyntax;
0acb30dd92bc The global Isabelle/Isar outer syntax.
wenzelm
parents:
diff changeset
   388
open BasicOuterSyntax;