src/HOL/Tools/string_code.ML
changeset 33989 cb136b5f6050
parent 31205 98370b26c2ce
child 37744 3daaf23b9ab4
equal deleted inserted replaced
33988:901001414358 33989:cb136b5f6050
    65 fun add_literal_char target =
    65 fun add_literal_char target =
    66   let
    66   let
    67     fun pretty literals nibbles' _ thm _ _ [(t1, _), (t2, _)] =
    67     fun pretty literals nibbles' _ thm _ _ [(t1, _), (t2, _)] =
    68       case decode_char nibbles' (t1, t2)
    68       case decode_char nibbles' (t1, t2)
    69        of SOME c => (Code_Printer.str o Code_Printer.literal_char literals) c
    69        of SOME c => (Code_Printer.str o Code_Printer.literal_char literals) c
    70         | NONE => Code_Printer.nerror thm "Illegal character expression";
    70         | NONE => Code_Printer.eqn_error thm "Illegal character expression";
    71   in Code_Target.add_syntax_const target
    71   in Code_Target.add_syntax_const target
    72     @{const_name Char} (SOME (2, (cs_nibbles, pretty)))
    72     @{const_name Char} (SOME (2, (cs_nibbles, pretty)))
    73   end;
    73   end;
    74 
    74 
    75 fun add_literal_string target =
    75 fun add_literal_string target =
    77     fun pretty literals (nil' :: cons' :: char' :: nibbles') _ thm _ _ [(t, _)] =
    77     fun pretty literals (nil' :: cons' :: char' :: nibbles') _ thm _ _ [(t, _)] =
    78       case List_Code.implode_list nil' cons' t
    78       case List_Code.implode_list nil' cons' t
    79        of SOME ts => (case implode_string char' nibbles'
    79        of SOME ts => (case implode_string char' nibbles'
    80           (Code_Printer.literal_char literals) (Code_Printer.literal_string literals) ts
    80           (Code_Printer.literal_char literals) (Code_Printer.literal_string literals) ts
    81              of SOME p => p
    81              of SOME p => p
    82               | NONE => Code_Printer.nerror thm "Illegal message expression")
    82               | NONE => Code_Printer.eqn_error thm "Illegal message expression")
    83         | NONE => Code_Printer.nerror thm "Illegal message expression";
    83         | NONE => Code_Printer.eqn_error thm "Illegal message expression";
    84   in Code_Target.add_syntax_const target 
    84   in Code_Target.add_syntax_const target 
    85     @{const_name STR} (SOME (1, (cs_summa, pretty)))
    85     @{const_name STR} (SOME (1, (cs_summa, pretty)))
    86   end;
    86   end;
    87 
    87 
    88 end;
    88 end;