comparison src/prim.sml @ 942:280f81731426

Escape character constants; lift indices properly in Reduce 'case' simplification
author Adam Chlipala <adamc@hcoop.net>
date Tue, 15 Sep 2009 12:41:54 -0400
parents 395a5d450cc0
children 4eb1c4a1b057
comparison
equal deleted inserted replaced
941:b8d7a47b8e0c 942:280f81731426
39 fun p_t t = 39 fun p_t t =
40 case t of 40 case t of
41 Int n => string (Int64.toString n) 41 Int n => string (Int64.toString n)
42 | Float n => string (Real64.toString n) 42 | Float n => string (Real64.toString n)
43 | String s => box [string "\"", string (String.toString s), string "\""] 43 | String s => box [string "\"", string (String.toString s), string "\""]
44 | Char ch => box [string "#\"", string (String.str ch), string "\""] 44 | Char ch => box [string "#\"", string (String.toString (String.str ch)), string "\""]
45 45
46 fun int2s n = 46 fun int2s n =
47 if Int64.compare (n, Int64.fromInt 0) = LESS then 47 if Int64.compare (n, Int64.fromInt 0) = LESS then
48 "-" ^ Int64.toString (Int64.~ n) ^ "LL" 48 "-" ^ Int64.toString (Int64.~ n) ^ "LL"
49 else 49 else
71 fun p_t_GCC t = 71 fun p_t_GCC t =
72 case t of 72 case t of
73 Int n => string (int2s n) 73 Int n => string (int2s n)
74 | Float n => string (float2s n) 74 | Float n => string (float2s n)
75 | String s => box [string "\"", string (String.toString s), string "\""] 75 | String s => box [string "\"", string (String.toString s), string "\""]
76 | Char ch => box [string "'", string (str ch), string "'"] 76 | Char ch => box [string "'", string (String.toString (str ch)), string "'"]
77 77
78 fun equal x = 78 fun equal x =
79 case x of 79 case x of
80 (Int n1, Int n2) => n1 = n2 80 (Int n1, Int n2) => n1 = n2
81 | (Float n1, Float n2) => Real64.== (n1, n2) 81 | (Float n1, Float n2) => Real64.== (n1, n2)