src/FOL/ex/NewLocaleSetup.thy
changeset 28873 2058a6b0eb20
child 28887 6f28fa3bc430
equal deleted inserted replaced
28872:686963dbf6cd 28873:2058a6b0eb20
       
     1 (*  Title:      FOL/ex/NewLocaleSetup.thy
       
     2     ID:         $Id$
       
     3     Author:     Clemens Ballarin, TU Muenchen
       
     4 
       
     5 Testing environment for locale expressions --- experimental.
       
     6 *)
       
     7 
       
     8 theory NewLocaleSetup
       
     9 imports FOL
       
    10 begin
       
    11 
       
    12 ML {*
       
    13 
       
    14 local
       
    15 
       
    16 structure P = OuterParse and K = OuterKeyword;
       
    17 val opt_bang = Scan.optional (P.$$$ "!" >> K true) false;
       
    18 
       
    19 val locale_val =
       
    20   Expression.parse_expression --
       
    21     Scan.optional (P.$$$ "+" |-- P.!!! (Scan.repeat1 SpecParse.context_element)) [] ||
       
    22   Scan.repeat1 SpecParse.context_element >> pair (Expression.empty_expr, []);
       
    23 
       
    24 in
       
    25 
       
    26 val _ =
       
    27   OuterSyntax.command "locale" "define named proof context" K.thy_decl
       
    28     (P.name -- Scan.optional (P.$$$ "=" |-- P.!!! locale_val) ((Expression.empty_expr, []), []) -- P.opt_begin
       
    29       >> (fn ((name, (expr, elems)), begin) =>
       
    30           (begin ? Toplevel.print) o Toplevel.begin_local_theory begin
       
    31             (Expression.add_locale name name expr elems #-> TheoryTarget.begin)));
       
    32 
       
    33 val _ =
       
    34   OuterSyntax.improper_command "print_locales" "print locales of this theory" K.diag
       
    35     (Scan.succeed (Toplevel.no_timing o (Toplevel.unknown_theory o
       
    36   Toplevel.keep (NewLocale.print_locales o Toplevel.theory_of))));
       
    37 
       
    38 val _ = OuterSyntax.improper_command "print_locale" "print named locale in this theory" K.diag
       
    39   (opt_bang -- P.xname >> (Toplevel.no_timing oo (fn (show_facts, name) =>
       
    40    Toplevel.unknown_theory o Toplevel.keep (fn state =>
       
    41      NewLocale.print_locale (Toplevel.theory_of state) show_facts name))));
       
    42 
       
    43 end
       
    44 
       
    45 *}
       
    46 
       
    47 end