clarified signature;
authorwenzelm
Thu, 25 Jan 2018 11:29:52 +0100
changeset 67504 310114bec0d7
parent 67503 7bb069073414
child 67505 ceb324e34c14
clarified signature;
src/Pure/Isar/method.ML
src/Pure/Isar/token.ML
--- a/src/Pure/Isar/method.ML	Thu Jan 25 11:20:31 2018 +0100
+++ b/src/Pure/Isar/method.ML	Thu Jan 25 11:29:52 2018 +0100
@@ -776,10 +776,12 @@
     val src2 = map Token.closure src1;
   in (text, src2) end;
 
-fun read_closure_input ctxt =
-  Input.source_explode
-  #> Token.read_body (Thy_Header.get_keywords' ctxt) (Scan.one Token.not_eof)
-  #> read_closure ctxt;
+fun read_closure_input ctxt input =
+  let val syms = Input.source_explode input in
+    (case Token.read_body (Thy_Header.get_keywords' ctxt) (Scan.many Token.not_eof) syms of
+      SOME res => read_closure ctxt res
+    | NONE => error ("Bad input" ^ Position.here (Input.pos_of input)))
+  end;
 
 val text_closure =
   Args.context -- Scan.lift (Parse.token Parse.text) >> (fn (ctxt, tok) =>
--- a/src/Pure/Isar/token.ML	Thu Jan 25 11:20:31 2018 +0100
+++ b/src/Pure/Isar/token.ML	Thu Jan 25 11:29:52 2018 +0100
@@ -93,7 +93,7 @@
   val make_src: string * Position.T -> T list -> src
   type 'a parser = T list -> 'a * T list
   type 'a context_parser = Context.generic * T list -> 'a * (Context.generic * T list)
-  val read_body: Keyword.keywords -> 'a parser -> Symbol_Pos.T list -> 'a list
+  val read_body: Keyword.keywords -> 'a parser -> Symbol_Pos.T list -> 'a option
   val read_antiq: Keyword.keywords -> 'a parser -> Symbol_Pos.T list * Position.T -> 'a
   val syntax_generic: 'a context_parser -> src -> Context.generic -> 'a * Context.generic
   val syntax: 'a context_parser -> src -> Proof.context -> 'a * Proof.context
@@ -712,14 +712,12 @@
 fun read_body keywords scan =
   tokenize (Keyword.no_command_keywords keywords) {strict = true}
   #> filter is_proper
-  #> Source.of_list
-  #> Source.source stopper (Scan.error (Scan.bulk scan))
-  #> Source.exhaust;
+  #> Scan.read stopper scan;
 
 fun read_antiq keywords scan (syms, pos) =
   (case read_body keywords scan syms of
-    [x] => x
-  | _ => error ("Malformed antiquotation" ^ Position.here pos));
+    SOME x => x
+  | NONE => error ("Malformed antiquotation" ^ Position.here pos));
 
 
 (* wrapped syntax *)