122 | expand (Antiquote.Antiq (ss, {range, ...})) ctxt = |
122 | expand (Antiquote.Antiq (ss, {range, ...})) ctxt = |
123 let |
123 let |
124 val keywords = Thy_Header.get_keywords' ctxt; |
124 val keywords = Thy_Header.get_keywords' ctxt; |
125 val (decl, ctxt') = |
125 val (decl, ctxt') = |
126 apply_antiquotation (Token.read_antiq keywords antiq (ss, #1 range)) ctxt; |
126 apply_antiquotation (Token.read_antiq keywords antiq (ss, #1 range)) ctxt; |
127 val decl' = decl #> pairself (ML_Lex.tokenize #> map (ML_Lex.set_range range)); |
127 val decl' = decl #> apply2 (ML_Lex.tokenize #> map (ML_Lex.set_range range)); |
128 in (decl', ctxt') end; |
128 in (decl', ctxt') end; |
129 |
129 |
130 val ctxt = |
130 val ctxt = |
131 (case opt_ctxt of |
131 (case opt_ctxt of |
132 NONE => error ("No context -- cannot expand ML antiquotations" ^ Position.here pos) |
132 NONE => error ("No context -- cannot expand ML antiquotations" ^ Position.here pos) |
133 | SOME ctxt => Context.proof_of ctxt); |
133 | SOME ctxt => Context.proof_of ctxt); |
134 |
134 |
135 val (decls, ctxt') = fold_map expand ants ctxt; |
135 val (decls, ctxt') = fold_map expand ants ctxt; |
136 val (ml_env, ml_body) = |
136 val (ml_env, ml_body) = |
137 decls |> map (fn decl => decl ctxt') |> split_list |> pairself flat; |
137 decls |> map (fn decl => decl ctxt') |> split_list |> apply2 flat; |
138 in ((begin_env visible @ ml_env, ml_body), SOME (Context.Proof ctxt')) end; |
138 in ((begin_env visible @ ml_env, ml_body), SOME (Context.Proof ctxt')) end; |
139 in ((ml_env @ end_env, ml_body), opt_ctxt') end; |
139 in ((ml_env @ end_env, ml_body), opt_ctxt') end; |
140 |
140 |
141 fun eval flags pos ants = |
141 fun eval flags pos ants = |
142 let |
142 let |