src/Pure/pure_syn.ML
author wenzelm
Wed, 24 Nov 2021 15:33:43 +0100
changeset 74838 4c8d9479f916
parent 74835 26c3a9c92e11
child 74881 1e84ae3e886e
permissions -rw-r--r--
more uniform treatment of optional_argument for Latex elements; discontinued somewhat pointless element position in Isabelle/Scala: semantic add-ons are better provided in Isabelle/ML; clarified signature of class Latex: overridable unknown_elem allows to extend the markup language;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48879
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/pure_syn.ML
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
     3
60096
7b98dbc1d13e tuned comment;
wenzelm
parents: 60095
diff changeset
     4
Outer syntax for bootstrapping: commands that are accessible outside a
7b98dbc1d13e tuned comment;
wenzelm
parents: 60095
diff changeset
     5
regular theory context.
48879
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
     6
*)
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
     7
60095
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
     8
signature PURE_SYN =
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
     9
sig
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    10
  val bootstrap_thy: theory
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    11
end;
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    12
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    13
structure Pure_Syn: PURE_SYN =
48879
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
    14
struct
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
    15
74835
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    16
fun document_heading (name, pos) =
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    17
  Outer_Syntax.command (name, pos) (name ^ " heading")
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    18
    (Parse.opt_target -- Parse.document_source --| Scan.option (Parse.$$$ ";") >>
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    19
      Document_Output.document_output
74838
4c8d9479f916 more uniform treatment of optional_argument for Latex elements;
wenzelm
parents: 74835
diff changeset
    20
        {markdown = false, markup = fn body => [XML.Elem (Markup.latex_heading name, body)]});
58918
8d36bc5eaed3 simplified keyword kinds;
wenzelm
parents: 58852
diff changeset
    21
74835
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    22
fun document_body ((name, pos), description) =
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    23
  Outer_Syntax.command (name, pos) description
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    24
    (Parse.opt_target -- Parse.document_source >>
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    25
      Document_Output.document_output
74838
4c8d9479f916 more uniform treatment of optional_argument for Latex elements;
wenzelm
parents: 74835
diff changeset
    26
        {markdown = true, markup = fn body => [XML.Elem (Markup.latex_body name, body)]});
58999
ed09ae4ea2d8 uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents: 58928
diff changeset
    27
ed09ae4ea2d8 uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents: 58928
diff changeset
    28
val _ =
74835
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    29
  List.app document_heading
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    30
   [("chapter", \<^here>),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    31
    ("section", \<^here>),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    32
    ("subsection", \<^here>),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    33
    ("subsubsection", \<^here>),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    34
    ("paragraph", \<^here>),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    35
    ("subparagraph", \<^here>)];
61463
8e46cea6a45a added 'paragraph', 'subparagraph';
wenzelm
parents: 61457
diff changeset
    36
8e46cea6a45a added 'paragraph', 'subparagraph';
wenzelm
parents: 61457
diff changeset
    37
val _ =
74835
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    38
  List.app document_body
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    39
   [(("text", \<^here>), "formal comment (primary style)"),
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    40
    (("txt", \<^here>), "formal comment (secondary style)")];
58999
ed09ae4ea2d8 uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents: 58928
diff changeset
    41
ed09ae4ea2d8 uniform treatment of all document markup commands: 'text' and 'txt' merely differ in LaTeX style;
wenzelm
parents: 58928
diff changeset
    42
val _ =
64556
851ae0e7b09c more symbols;
wenzelm
parents: 62912
diff changeset
    43
  Outer_Syntax.command ("text_raw", \<^here>) "LaTeX text (without surrounding environment)"
74835
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    44
    (Parse.opt_target -- Parse.document_source >>
26c3a9c92e11 more general document output: enclosing markup is defined in user-space;
wenzelm
parents: 74832
diff changeset
    45
      Document_Output.document_output
74838
4c8d9479f916 more uniform treatment of optional_argument for Latex elements;
wenzelm
parents: 74835
diff changeset
    46
        {markdown = true, markup = Latex.enclose_text "%\n" "\n"});
58928
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents: 58918
diff changeset
    47
23d0ffd48006 plain value Keywords.keywords, which might be used outside theory for bootstrap purposes;
wenzelm
parents: 58918
diff changeset
    48
val _ =
64556
851ae0e7b09c more symbols;
wenzelm
parents: 62912
diff changeset
    49
  Outer_Syntax.command ("theory", \<^here>) "begin theory"
58852
621c052789b4 obsolete;
wenzelm
parents: 58842
diff changeset
    50
    (Thy_Header.args >>
621c052789b4 obsolete;
wenzelm
parents: 58842
diff changeset
    51
      (fn _ => Toplevel.init_theory (fn () => error "Missing theory initialization")));
48879
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
    52
60095
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    53
62876
507c90523113 clarified modules -- simplified bootstrap;
wenzelm
parents: 62453
diff changeset
    54
val bootstrap_thy = Context.the_global_context ();
60095
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    55
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    56
val _ = Theory.setup (Config.put_global Outer_Syntax.bootstrap false);
35f626b11422 more explicit bootstrap_thy;
wenzelm
parents: 58999
diff changeset
    57
48879
cb5cdbb645cd clarified bootstrapping of Pure;
wenzelm
parents:
diff changeset
    58
end;