| author | wenzelm | 
| Tue, 23 Nov 2021 21:02:13 +0100 | |
| changeset 74836 | a97ec0954c50 | 
| parent 72739 | e7c2848b78e8 | 
| child 81113 | 6fefd6c602fa | 
| permissions | -rw-r--r-- | 
| 36952 
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 1 | (* Title: Pure/Isar/parse_spec.ML | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 2 | Author: Makarius | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 3 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 4 | Parsers for complex specifications. | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 5 | *) | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 6 | |
| 36952 
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 7 | signature PARSE_SPEC = | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 8 | sig | 
| 29312 | 9 | val thm_name: string -> Attrib.binding parser | 
| 10 | val opt_thm_name: string -> Attrib.binding parser | |
| 58011 
bc6bced136e5
tuned signature -- moved type src to Token, without aliases;
 wenzelm parents: 
56945diff
changeset | 11 | val name_facts: (Attrib.binding * (Facts.ref * Token.src list) list) list parser | 
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 12 | val simple_spec: (Attrib.binding * string) parser | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 13 | val simple_specs: (Attrib.binding * string list) parser | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 14 | val if_assumes: string list parser | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 15 | val multi_specs: Specification.multi_specs_cmd parser | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 16 | val where_multi_specs: Specification.multi_specs_cmd parser | 
| 63183 | 17 | val specification: | 
| 18 | ((binding * string option * mixfix) list * Specification.multi_specs_cmd) parser | |
| 33287 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 19 | val constdecl: (binding * string option * mixfix) parser | 
| 47067 
4ef29b0c568f
optional 'includes' element for long theorem statements;
 wenzelm parents: 
46922diff
changeset | 20 | val includes: (xstring * Position.T) list parser | 
| 72739 
e7c2848b78e8
refined syntax for bundle mixins for locale and class specifications
 haftmann parents: 
72536diff
changeset | 21 | val opening: (xstring * Position.T) list parser | 
| 29581 | 22 | val locale_fixes: (binding * string option * mixfix) list parser | 
| 29312 | 23 | val locale_insts: (string option list * (Attrib.binding * string) list) parser | 
| 46922 
3717f3878714
source positions for locale and class expressions;
 wenzelm parents: 
45592diff
changeset | 24 | val class_expression: string list parser | 
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 25 | val locale_prefix: (string * bool) parser | 
| 49754 
acafcac41690
more explicit namespace prefix for 'statespace' -- duplicate facts;
 wenzelm parents: 
47067diff
changeset | 26 | val locale_keyword: string parser | 
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 27 | val locale_expression: Expression.expression parser | 
| 29312 | 28 | val context_element: Element.context parser | 
| 61654 
4a28eec739e9
support for structure statements in 'assume', 'presume';
 wenzelm parents: 
61606diff
changeset | 29 | val statement': (string * string list) list list parser | 
| 
4a28eec739e9
support for structure statements in 'assume', 'presume';
 wenzelm parents: 
61606diff
changeset | 30 | val if_statement': (string * string list) list list parser | 
| 29312 | 31 | val statement: (Attrib.binding * (string * string list) list) list parser | 
| 60449 | 32 | val if_statement: (Attrib.binding * (string * string list) list) list parser | 
| 60555 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 33 | val cond_statement: (bool * (Attrib.binding * (string * string list) list) list) parser | 
| 60448 | 34 | val obtains: Element.obtains parser | 
| 63094 
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
 wenzelm parents: 
63064diff
changeset | 35 | val long_statement: (Element.context list * Element.statement) parser | 
| 
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
 wenzelm parents: 
63064diff
changeset | 36 | val long_statement_keyword: string parser | 
| 61260 | 37 | val overloaded: bool parser | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 38 | end; | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 39 | |
| 36952 
338c3f8229e4
renamed structure SpecParse to Parse_Spec, keeping the old name as alias for some time;
 wenzelm parents: 
36950diff
changeset | 40 | structure Parse_Spec: PARSE_SPEC = | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 41 | struct | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 42 | |
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 43 | (* simple specifications *) | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 44 | |
| 58028 
e4250d370657
tuned signature -- define some elementary operations earlier;
 wenzelm parents: 
58011diff
changeset | 45 | fun thm_name s = Parse.binding -- Parse.opt_attribs --| Parse.$$$ s; | 
| 28083 
103d9282a946
explicit type Name.binding for higher-specification elements;
 wenzelm parents: 
27816diff
changeset | 46 | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 47 | fun opt_thm_name s = | 
| 58028 
e4250d370657
tuned signature -- define some elementary operations earlier;
 wenzelm parents: 
58011diff
changeset | 48 | Scan.optional | 
| 
e4250d370657
tuned signature -- define some elementary operations earlier;
 wenzelm parents: 
58011diff
changeset | 49 | ((Parse.binding -- Parse.opt_attribs || Parse.attribs >> pair Binding.empty) --| Parse.$$$ s) | 
| 63352 | 50 | Binding.empty_atts; | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 51 | |
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 52 | val simple_spec = opt_thm_name ":" -- Parse.prop; | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 53 | val simple_specs = opt_thm_name ":" -- Scan.repeat1 Parse.prop; | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 54 | |
| 62969 | 55 | val name_facts = Parse.and_list1 (opt_thm_name "=" -- Parse.thms1); | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 56 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 57 | |
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 58 | (* structured specifications *) | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 59 | |
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 60 | val if_assumes = | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 61 | Scan.optional (Parse.$$$ "if" |-- Parse.!!! (Parse.and_list1 (Scan.repeat1 Parse.prop) >> flat)) | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 62 | []; | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 63 | |
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 64 | val multi_specs = | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 65 | Parse.enum1 "|" | 
| 63182 | 66 | ((opt_thm_name ":" -- Parse.prop -- if_assumes -- Parse.for_fixes >> Scan.triple1) --| | 
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 67 | Scan.option (Scan.ahead (Parse.name || Parse.$$$ "[") -- Parse.!!! (Parse.$$$ "|"))); | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 68 | |
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 69 | val where_multi_specs = Parse.where_ |-- Parse.!!! multi_specs; | 
| 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 70 | |
| 63285 | 71 | val specification = Parse.vars -- where_multi_specs; | 
| 63183 | 72 | |
| 63064 
2f18172214c8
support 'assumes' in specifications, e.g. 'definition', 'inductive';
 wenzelm parents: 
62969diff
changeset | 73 | |
| 33287 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 74 | (* basic constant specifications *) | 
| 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 75 | |
| 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 76 | val constdecl = | 
| 36950 | 77 | Parse.binding -- | 
| 78 | (Parse.where_ >> K (NONE, NoSyn) || | |
| 79 | Parse.$$$ "::" |-- Parse.!!! ((Parse.typ >> SOME) -- Parse.opt_mixfix' --| Parse.where_) || | |
| 80 |       Scan.ahead (Parse.$$$ "(") |-- Parse.!!! (Parse.mixfix' --| Parse.where_ >> pair NONE))
 | |
| 61466 | 81 | >> Scan.triple2; | 
| 33287 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 82 | |
| 
0f99569d23e1
provide SpecParse.constdecl/constdef, e.g. for quotient_definition;
 wenzelm parents: 
30726diff
changeset | 83 | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 84 | (* locale and context elements *) | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 85 | |
| 69349 
7cef9e386ffe
more accurate positions for "name" (quoted string) and "embedded" (cartouche): refer to content without delimiters, which is e.g. relevant for systematic selection/renaming of scope groups;
 wenzelm parents: 
67740diff
changeset | 86 | val includes = Parse.$$$ "includes" |-- Parse.!!! (Scan.repeat1 Parse.name_position); | 
| 47067 
4ef29b0c568f
optional 'includes' element for long theorem statements;
 wenzelm parents: 
46922diff
changeset | 87 | |
| 72739 
e7c2848b78e8
refined syntax for bundle mixins for locale and class specifications
 haftmann parents: 
72536diff
changeset | 88 | val opening = Parse.$$$ "opening" |-- Parse.!!! (Scan.repeat1 Parse.name_position); | 
| 
e7c2848b78e8
refined syntax for bundle mixins for locale and class specifications
 haftmann parents: 
72536diff
changeset | 89 | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 90 | val locale_fixes = | 
| 51654 
8450b944e58a
just one syntax category "mixfix" -- check structure annotation semantically;
 wenzelm parents: 
49754diff
changeset | 91 | Parse.and_list1 (Parse.binding -- Scan.option (Parse.$$$ "::" |-- Parse.typ) -- Parse.mixfix | 
| 61466 | 92 | >> (single o Scan.triple1) || | 
| 60448 | 93 | Parse.params) >> flat; | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 94 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 95 | val locale_insts = | 
| 36950 | 96 | Scan.optional | 
| 97 | (Parse.$$$ "[" |-- Parse.!!! (Scan.repeat1 (Parse.maybe Parse.term) --| Parse.$$$ "]")) [] -- | |
| 98 | Scan.optional (Parse.where_ |-- Parse.and_list1 (opt_thm_name ":" -- Parse.prop)) []; | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 99 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 100 | local | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 101 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 102 | val loc_element = | 
| 36950 | 103 | Parse.$$$ "fixes" |-- Parse.!!! locale_fixes >> Element.Fixes || | 
| 104 | Parse.$$$ "constrains" |-- | |
| 105 | Parse.!!! (Parse.and_list1 (Parse.name -- (Parse.$$$ "::" |-- Parse.typ))) | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 106 | >> Element.Constrains || | 
| 36950 | 107 | Parse.$$$ "assumes" |-- Parse.!!! (Parse.and_list1 (opt_thm_name ":" -- Scan.repeat1 Parse.propp)) | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 108 | >> Element.Assumes || | 
| 36950 | 109 | Parse.$$$ "defines" |-- Parse.!!! (Parse.and_list1 (opt_thm_name ":" -- Parse.propp)) | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 110 | >> Element.Defines || | 
| 62969 | 111 | Parse.$$$ "notes" |-- Parse.!!! (Parse.and_list1 (opt_thm_name "=" -- Parse.thms1)) | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 112 | >> (curry Element.Notes ""); | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 113 | |
| 24869 | 114 | fun plus1_unless test scan = | 
| 36950 | 115 | scan ::: Scan.repeat (Parse.$$$ "+" |-- Scan.unless test (Parse.!!! scan)); | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 116 | |
| 67450 
b0ae74b86ef3
Experimental support for rewrite morphisms in locale instances.
 ballarin parents: 
63352diff
changeset | 117 | val instance = Scan.optional (Parse.where_ |-- | 
| 36950 | 118 | Parse.and_list1 (Parse.name -- (Parse.$$$ "=" |-- Parse.term)) >> Expression.Named || | 
| 67450 
b0ae74b86ef3
Experimental support for rewrite morphisms in locale instances.
 ballarin parents: 
63352diff
changeset | 119 | Scan.repeat1 (Parse.maybe Parse.term) >> Expression.Positional) (Expression.Named []) -- | 
| 67740 | 120 | (Scan.optional (Parse.$$$ "rewrites" |-- Parse.and_list1 (opt_thm_name ":" -- Parse.prop)) []); | 
| 29033 
721529248e31
Enable keyword 'structure' in for clause of locale expression.
 ballarin parents: 
28965diff
changeset | 121 | |
| 24869 | 122 | in | 
| 123 | ||
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 124 | val locale_prefix = | 
| 49754 
acafcac41690
more explicit namespace prefix for 'statespace' -- duplicate facts;
 wenzelm parents: 
47067diff
changeset | 125 | Scan.optional | 
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 126 | (Parse.name -- (Scan.option (Parse.$$$ "?") >> is_none) --| Parse.$$$ ":") | 
| 49754 
acafcac41690
more explicit namespace prefix for 'statespace' -- duplicate facts;
 wenzelm parents: 
47067diff
changeset | 127 |     ("", false);
 | 
| 
acafcac41690
more explicit namespace prefix for 'statespace' -- duplicate facts;
 wenzelm parents: 
47067diff
changeset | 128 | |
| 36950 | 129 | val locale_keyword = | 
| 130 | Parse.$$$ "fixes" || Parse.$$$ "constrains" || Parse.$$$ "assumes" || | |
| 131 | Parse.$$$ "defines" || Parse.$$$ "notes"; | |
| 28722 | 132 | |
| 72536 
589645894305
bundle mixins for locale and class specifications
 haftmann parents: 
69349diff
changeset | 133 | val locale_keyword' = | 
| 
589645894305
bundle mixins for locale and class specifications
 haftmann parents: 
69349diff
changeset | 134 | Parse.$$$ "includes" || locale_keyword; | 
| 
589645894305
bundle mixins for locale and class specifications
 haftmann parents: 
69349diff
changeset | 135 | |
| 
589645894305
bundle mixins for locale and class specifications
 haftmann parents: 
69349diff
changeset | 136 | val class_expression = plus1_unless locale_keyword' Parse.class; | 
| 24869 | 137 | |
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 138 | val locale_expression = | 
| 29033 
721529248e31
Enable keyword 'structure' in for clause of locale expression.
 ballarin parents: 
28965diff
changeset | 139 | let | 
| 69349 
7cef9e386ffe
more accurate positions for "name" (quoted string) and "embedded" (cartouche): refer to content without delimiters, which is e.g. relevant for systematic selection/renaming of scope groups;
 wenzelm parents: 
67740diff
changeset | 140 | val expr2 = Parse.name_position; | 
| 61606 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 141 | val expr1 = | 
| 
6d5213bd9709
uniform mandatory qualifier for all locale expressions, including 'statespace' parent;
 wenzelm parents: 
61466diff
changeset | 142 | locale_prefix -- expr2 -- | 
| 67450 
b0ae74b86ef3
Experimental support for rewrite morphisms in locale instances.
 ballarin parents: 
63352diff
changeset | 143 | instance >> (fn ((p, l), i) => (l, (p, i))); | 
| 72536 
589645894305
bundle mixins for locale and class specifications
 haftmann parents: 
69349diff
changeset | 144 | val expr0 = plus1_unless locale_keyword' expr1; | 
| 36950 | 145 | in expr0 -- Scan.optional (Parse.$$$ "for" |-- Parse.!!! locale_fixes) [] end; | 
| 29033 
721529248e31
Enable keyword 'structure' in for clause of locale expression.
 ballarin parents: 
28965diff
changeset | 146 | |
| 44357 | 147 | val context_element = Parse.group (fn () => "context element") loc_element; | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 148 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 149 | end; | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 150 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 151 | |
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 152 | (* statements *) | 
| 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 153 | |
| 61654 
4a28eec739e9
support for structure statements in 'assume', 'presume';
 wenzelm parents: 
61606diff
changeset | 154 | val statement' = Parse.and_list1 (Scan.repeat1 Parse.propp); | 
| 
4a28eec739e9
support for structure statements in 'assume', 'presume';
 wenzelm parents: 
61606diff
changeset | 155 | val if_statement' = Scan.optional (Parse.$$$ "if" |-- Parse.!!! statement') []; | 
| 
4a28eec739e9
support for structure statements in 'assume', 'presume';
 wenzelm parents: 
61606diff
changeset | 156 | |
| 36950 | 157 | val statement = Parse.and_list1 (opt_thm_name ":" -- Scan.repeat1 Parse.propp); | 
| 60449 | 158 | val if_statement = Scan.optional (Parse.$$$ "if" |-- Parse.!!! statement) []; | 
| 60414 | 159 | |
| 60555 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 160 | val cond_statement = | 
| 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 161 | Parse.$$$ "if" |-- Parse.!!! statement >> pair true || | 
| 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 162 | Parse.$$$ "when" |-- Parse.!!! statement >> pair false || | 
| 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 163 | Scan.succeed (true, []); | 
| 
51a6997b1384
support 'when' statement, which corresponds to 'presume';
 wenzelm parents: 
60449diff
changeset | 164 | |
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 165 | val obtain_case = | 
| 59784 | 166 | Parse.parbinding -- | 
| 63285 | 167 | (Scan.optional (Parse.and_list1 Parse.vars --| Parse.where_ >> flat) [] -- | 
| 59784 | 168 | (Parse.and_list1 (Scan.repeat1 Parse.prop) >> flat)); | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 169 | |
| 60448 | 170 | val obtains = Parse.enum1 "|" obtain_case; | 
| 171 | ||
| 63094 
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
 wenzelm parents: 
63064diff
changeset | 172 | val long_statement = | 
| 28722 | 173 | Scan.repeat context_element -- | 
| 60448 | 174 | (Parse.$$$ "obtains" |-- Parse.!!! obtains >> Element.Obtains || | 
| 36950 | 175 | Parse.$$$ "shows" |-- Parse.!!! statement >> Element.Shows); | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 176 | |
| 63094 
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
 wenzelm parents: 
63064diff
changeset | 177 | val long_statement_keyword = | 
| 
056ea294c256
toplevel theorem statements support 'if'/'for' eigen-context;
 wenzelm parents: 
63064diff
changeset | 178 | locale_keyword || Parse.$$$ "obtains" || Parse.$$$ "shows"; | 
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 179 | |
| 61260 | 180 | |
| 181 | (* options *) | |
| 182 | ||
| 183 | val overloaded = | |
| 184 |   Scan.optional (Parse.$$$ "(" -- Parse.$$$ "overloaded" -- Parse.$$$ ")" >> K true) false;
 | |
| 185 | ||
| 22104 
e8a1c88be824
Parsers for complex specifications (material from outer_parse.ML);
 wenzelm parents: diff
changeset | 186 | end; |