| 1 |
(* Copyright (C) 2004-2008 Henry Cejtin, Matthew Fluet, Suresh |
| 2 |
* Jagannathan, and Stephen Weeks. |
| 3 |
* |
| 4 |
* MLton is released under a HPND-style license. |
| 5 |
* See the file MLton-LICENSE for details. |
| 6 |
*) |
| 7 |
|
| 8 |
structure List = |
| 9 |
struct |
| 10 |
fun foreach (l, f) = List.app f l |
| 11 |
fun map (l, f) = List.map f l |
| 12 |
val tabulate = List.tabulate |
| 13 |
end |
| 14 |
|
| 15 |
val int = |
| 16 |
["Int", "IntInf", "LargeInt", "FixedInt", "Position"] |
| 17 |
@ List.map (List.tabulate (31, fn i => i + 2) @ [64], |
| 18 |
fn i => concat ["Int", Int.toString i]) |
| 19 |
|
| 20 |
val real = ["Real", "Real32", "Real64", "LargeReal"] |
| 21 |
|
| 22 |
val word = |
| 23 |
["Word", "LargeWord", "SysWord"] |
| 24 |
@ List.map (List.tabulate (32, fn i => i + 1) @ [64], |
| 25 |
fn i => concat ["Word", Int.toString i]) |
| 26 |
|
| 27 |
val text = ["Char", "WideChar", "String", "WideString"] |
| 28 |
|
| 29 |
(* Order matters here in the appends, since the first element will be the |
| 30 |
* default. |
| 31 |
*) |
| 32 |
val num = int @ word @ real |
| 33 |
val numtext = num @ text |
| 34 |
val realint = int @ real |
| 35 |
val wordint = int @ word |
| 36 |
|
| 37 |
val binary = "'a * 'a -> 'a" |
| 38 |
val compare = "'a * 'a -> bool" |
| 39 |
val unary = "'a -> 'a" |
| 40 |
|
| 41 |
val () = print "(* This file is automatically generated. Do not edit. *)\n" |
| 42 |
|
| 43 |
val () = |
| 44 |
List.foreach |
| 45 |
([(2, "~", unary, num), |
| 46 |
(2, "+", binary, num), |
| 47 |
(2, "-", binary, num), |
| 48 |
(2, "*", binary, num), |
| 49 |
(4, "/", binary, real), |
| 50 |
(3, "div", binary, wordint), |
| 51 |
(3, "mod", binary, wordint), |
| 52 |
(3, "abs", unary, realint), |
| 53 |
(1, "<", compare, numtext), |
| 54 |
(1, "<=", compare, numtext), |
| 55 |
(1, ">", compare, numtext), |
| 56 |
(1, ">=", compare, numtext)], |
| 57 |
fn (prec, f, ty, class) => |
| 58 |
(print (concat ["\n_overload ", Int.toString prec, " ", f, " : ", ty, "\n"]) |
| 59 |
; (case class of |
| 60 |
[] => () |
| 61 |
| c :: class => |
| 62 |
(print (concat ["as ", c, ".", f, "\n"]) |
| 63 |
; List.foreach (class, fn c => |
| 64 |
print (concat ["and ", c, ".", f, "\n"])))))) |