2697
|
1 |
(* Title: Pure/Syntax/token_trans.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Markus Wenzel, TU Muenchen
|
|
4 |
|
|
5 |
Token translations for xterm and LaTeX output.
|
|
6 |
*)
|
|
7 |
|
|
8 |
signature TOKEN_TRANS =
|
|
9 |
sig
|
|
10 |
val token_translation: (string * string * (string -> string * int)) list
|
|
11 |
end;
|
|
12 |
|
|
13 |
structure TokenTrans: TOKEN_TRANS =
|
|
14 |
struct
|
|
15 |
|
|
16 |
(** misc utils **)
|
|
17 |
|
|
18 |
fun trans_mode m trs = map (fn (s, f) => (m, s, f)) trs;
|
|
19 |
|
|
20 |
val tok_classes = ["class", "tfree", "tvar", "free", "bound", "var"];
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
(** xterm output **)
|
|
25 |
|
|
26 |
(* styles *)
|
|
27 |
|
|
28 |
val normal = "\^[[0m";
|
|
29 |
val bold = "\^[[1m";
|
|
30 |
val underline = "\^[[4m";
|
|
31 |
|
|
32 |
fun style s x = (s ^ x ^ normal, size x);
|
|
33 |
|
|
34 |
|
|
35 |
val xterm_trans =
|
|
36 |
trans_mode "xterm"
|
|
37 |
[("bound", style underline),
|
|
38 |
("free", style bold),
|
|
39 |
("var", style bold),
|
|
40 |
("tfree", style bold),
|
|
41 |
("tvar", style bold)];
|
|
42 |
|
|
43 |
(* FIXME xterm-color *)
|
|
44 |
|
|
45 |
|
|
46 |
(** LaTeX output **)
|
|
47 |
|
|
48 |
(* FIXME 'a -> \alpha etc. *)
|
|
49 |
|
|
50 |
|
|
51 |
(** token translations **)
|
|
52 |
|
|
53 |
val token_translation =
|
|
54 |
map (fn s => ("", s, fn x => (x, size x))) tok_classes @
|
|
55 |
(* FIXME tmp test *)
|
|
56 |
map (fn s => ("test", s, fn x => (s ^ "[" ^ x ^ "]", size x + size s + 2))) tok_classes @
|
|
57 |
xterm_trans;
|
|
58 |
|
|
59 |
|
|
60 |
end;
|