doc-src/antiquote_setup.ML
changeset 39858 5be7a57c3b4e
parent 39829 f5ea50decd9f
child 39869 c269f6bd0a1f
equal deleted inserted replaced
39857:ea93e088398d 39858:5be7a57c3b4e
    42 (* ML text *)
    42 (* ML text *)
    43 
    43 
    44 local
    44 local
    45 
    45 
    46 fun ml_val (txt1, "") = "fn _ => (" ^ txt1 ^ ");"
    46 fun ml_val (txt1, "") = "fn _ => (" ^ txt1 ^ ");"
    47   | ml_val (txt1, txt2) = "fn _ => (" ^ txt1 ^ ": " ^ txt2 ^ ");";
    47   | ml_val (txt1, txt2) = "fn _ => (" ^ txt1 ^ " : " ^ txt2 ^ ");";
    48 
    48 
    49 fun ml_type (txt1, "") = "val _ = NONE : (" ^ txt1 ^ ") option;"
    49 fun ml_type (txt1, "") = "val _ = NONE : (" ^ txt1 ^ ") option;"
    50   | ml_type (txt1, txt2) = "val _ = [NONE : (" ^ txt1 ^ ") option, NONE : (" ^ txt2 ^ ") option];";
    50   | ml_type (txt1, txt2) = "val _ = [NONE : (" ^ txt1 ^ ") option, NONE : (" ^ txt2 ^ ") option];";
    51 
    51 
    52 fun ml_exn (txt1, "") = "fn _ => (" ^ txt1 ^ ": exn);"
    52 fun ml_exn (txt1, "") = "fn _ => (" ^ txt1 ^ " : exn);"
    53   | ml_exn (txt1, txt2) = "fn _ => (" ^ txt1 ^ ": " ^ txt2 ^ " -> exn);";
    53   | ml_exn (txt1, txt2) = "fn _ => (" ^ txt1 ^ " : " ^ txt2 ^ " -> exn);";
    54 
    54 
    55 fun ml_structure (txt, _) = "functor XXX() = struct structure XX = " ^ txt ^ " end;";
    55 fun ml_structure (txt, _) = "functor XXX() = struct structure XX = " ^ txt ^ " end;";
    56 
    56 
    57 fun ml_functor (txt, _) = "ML_Env.check_functor " ^ ML_Syntax.print_string txt;
    57 fun ml_functor (txt, _) = "ML_Env.check_functor " ^ ML_Syntax.print_string txt;
    58 
    58 
    62     let
    62     let
    63       val txt =
    63       val txt =
    64         if txt2 = "" then txt1
    64         if txt2 = "" then txt1
    65         else if kind = "type" then txt1 ^ " = " ^ txt2
    65         else if kind = "type" then txt1 ^ " = " ^ txt2
    66         else if kind = "exception" then txt1 ^ " of " ^ txt2
    66         else if kind = "exception" then txt1 ^ " of " ^ txt2
    67         else txt1 ^ ": " ^ txt2;
    67         else if Syntax.is_identifier (Long_Name.base_name txt1) then txt1 ^ ": " ^ txt2
       
    68         else txt1 ^ " : " ^ txt2;
    68       val txt' = if kind = "" then txt else kind ^ " " ^ txt;
    69       val txt' = if kind = "" then txt else kind ^ " " ^ txt;
    69       val _ = ML_Context.eval_text_in (SOME ctxt) false Position.none (ml (txt1, txt2));  (* ML_Lex.read (!?) *)
    70       val _ = ML_Context.eval_text_in (SOME ctxt) false Position.none (ml (txt1, txt2));  (* ML_Lex.read (!?) *)
    70       val kind' = if kind = "" then "ML" else "ML " ^ kind;
    71       val kind' = if kind = "" then "ML" else "ML " ^ kind;
    71     in
    72     in
    72       "\\indexdef{}{" ^ kind' ^ "}{" ^ clean_string txt1 ^ "}" ^
    73       "\\indexdef{}{" ^ kind' ^ "}{" ^ clean_string txt1 ^ "}" ^