1 (* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
9 functor AstConst (S: AST_CONST_STRUCTS): AST_CONST =
19 | String of IntInf.t vector
21 type t = node Region.Wrap.t
25 fun ordToString (c: IntInf.t): string =
27 fun loop (n: int, c: IntInf.t, ac: char list) =
32 val (q, r) = IntInf.quotRem (c, 0x10)
34 loop (n - 1, q, Char.fromHexDigit (Int.fromIntInf r) :: ac)
36 fun doit (n, esc) = concat ["\\", esc, loop (n, c, [])]
39 then Char.escapeSML (Char.fromInt (Int.fromIntInf c))
50 Bool b => if b then str "true" else str "false"
51 | Char c => str (concat ["#\"", ordToString c, "\""])
52 | Int s => str (IntInf.toString s)
53 | Real l => String.layout l
55 str (concat ["\"", concat (Vector.toListMap (s, ordToString)), "\""])
56 | Word w => str (concat ["0wx", IntInf.format (w, StringCvt.HEX)])