src/Pure/Isar/token.ML
changeset 61822 a16497c686cb
parent 61820 e65344e3eeb5
child 61825 69b035408b18
equal deleted inserted replaced
61821:b8a3deee50db 61822:a16497c686cb
    62   val print: T -> string
    62   val print: T -> string
    63   val text_of: T -> string * string
    63   val text_of: T -> string * string
    64   val get_files: T -> file Exn.result list
    64   val get_files: T -> file Exn.result list
    65   val put_files: file Exn.result list -> T -> T
    65   val put_files: file Exn.result list -> T -> T
    66   val get_value: T -> value option
    66   val get_value: T -> value option
       
    67   val reports_of_value: T -> Position.report list
    67   val name_value: name_value -> value
    68   val name_value: name_value -> value
    68   val get_name: T -> name_value option
    69   val get_name: T -> name_value option
    69   val reports_of_value: T -> Position.report list
       
    70   val declare_maxidx: T -> Proof.context -> Proof.context
    70   val declare_maxidx: T -> Proof.context -> Proof.context
    71   val map_facts: (string option -> thm list -> thm list) -> T -> T
    71   val map_facts: (string option -> thm list -> thm list) -> T -> T
    72   val transform: morphism -> T -> T
    72   val transform: morphism -> T -> T
    73   val init_assignable: T -> T
    73   val init_assignable: T -> T
    74   val assign: value option -> T -> T
    74   val assign: value option -> T -> T
   358 (* access values *)
   358 (* access values *)
   359 
   359 
   360 fun get_value (Token (_, _, Value v)) = v
   360 fun get_value (Token (_, _, Value v)) = v
   361   | get_value _ = NONE;
   361   | get_value _ = NONE;
   362 
   362 
       
   363 fun map_value f (Token (x, y, Value (SOME v))) = Token (x, y, Value (SOME (f v)))
       
   364   | map_value _ tok = tok;
       
   365 
       
   366 
       
   367 (* reports of value *)
       
   368 
   363 fun get_assignable_value (Token (_, _, Assignable r)) = ! r
   369 fun get_assignable_value (Token (_, _, Assignable r)) = ! r
   364   | get_assignable_value (Token (_, _, Value v)) = v
   370   | get_assignable_value (Token (_, _, Value v)) = v
   365   | get_assignable_value _ = NONE;
   371   | get_assignable_value _ = NONE;
   366 
       
   367 fun map_value f (Token (x, y, Value (SOME v))) = Token (x, y, Value (SOME (f v)))
       
   368   | map_value _ tok = tok;
       
   369 
       
   370 
       
   371 (* name value *)
       
   372 
       
   373 fun name_value a = Name (a, Morphism.identity);
       
   374 
       
   375 fun get_name tok =
       
   376   (case get_assignable_value tok of
       
   377     SOME (Name (a, _)) => SOME a
       
   378   | _ => NONE);
       
   379 
       
   380 
       
   381 (* reports of value *)
       
   382 
   372 
   383 fun reports_of_value tok =
   373 fun reports_of_value tok =
   384   (case get_assignable_value tok of
   374   (case get_assignable_value tok of
   385     SOME (Literal markup) =>
   375     SOME (Literal markup) =>
   386       let
   376       let
   390         if Position.is_reported pos then
   380         if Position.is_reported pos then
   391           map (pair pos) (keyword_markup markup x :: Completion.suppress_abbrevs x)
   381           map (pair pos) (keyword_markup markup x :: Completion.suppress_abbrevs x)
   392         else []
   382         else []
   393       end
   383       end
   394   | _ => []);
   384   | _ => []);
       
   385 
       
   386 
       
   387 (* name value *)
       
   388 
       
   389 fun name_value a = Name (a, Morphism.identity);
       
   390 
       
   391 fun get_name tok =
       
   392   (case get_assignable_value tok of
       
   393     SOME (Name (a, _)) => SOME a
       
   394   | _ => NONE);
   395 
   395 
   396 
   396 
   397 (* maxidx *)
   397 (* maxidx *)
   398 
   398 
   399 fun declare_maxidx tok =
   399 fun declare_maxidx tok =