Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / Enscript.adoc
1 Enscript
2 ========
3
4 http://www.gnu.org/s/enscript/[GNU Enscript] converts ASCII files to
5 PostScript, HTML, and other output languages, applying language
6 sensitive highlighting (similar to <:Emacs:>'s font lock mode). Here
7 are a few _states_ files for highlighting <:StandardML: Standard ML>.
8
9 * <!ViewGitFile(mlton,master,ide/enscript/sml_simple.st)> -- Provides highlighting of keywords, string and character constants, and (nested) comments.
10 /////
11 +
12 [source,sml]
13 ----
14 (* Comments (* can be nested *) *)
15 structure S = struct
16 val x = (1, 2, "three")
17 end
18 ----
19 /////
20
21 * <!ViewGitFile(mlton,master,ide/enscript/sml_verbose.st)> -- Supersedes
22 the above, adding highlighting of numeric constants. Due to the
23 limited parsing available, numeric record labels are highlighted as
24 numeric constants, in all contexts. Likewise, a binding precedence
25 separated from `infix` or `infixr` by a newline is highlighted as a
26 numeric constant and a numeric record label selector separated from
27 `#` by a newline is highlighted as a numeric constant.
28 /////
29 +
30 [source,sml]
31 ----
32 structure S = struct
33 (* These look good *)
34 val x = (1, 2, "three")
35 val z = #2 x
36
37 (* Although these look bad (not all the numbers are constants), *
38 * they never occur in practice, as they are equivalent to the above. *)
39 val x = {1 = 1, 3 = "three", 2 = 2}
40 val z = #
41 2 x
42 end
43 ----
44 /////
45
46 * <!ViewGitFile(mlton,master,ide/enscript/sml_fancy.st)> -- Supersedes the
47 above, adding highlighting of type and constructor bindings,
48 highlighting of explicit binding of type variables at `val` and `fun`
49 declarations, and separate highlighting of core and modules level
50 keywords. Due to the limited parsing available, it is assumed that
51 the input is a syntactically correct, top-level declaration.
52 /////
53 +
54 [source,sml]
55 ----
56 structure S = struct
57 val x = (1, 2, "three")
58 datatype 'a t = T of 'a
59 and u = U of v * v
60 withtype v = {left: int t, right: int t}
61 exception E1 of int and E2
62 fun 'a id (x: 'a) : 'a = x
63
64 (* Although this looks bad (the explicitly bound type variable 'a is *
65 * not highlighted), it is unlikely to occur in practice. *)
66 val
67 'a id = fn (x : 'a) => x
68 end
69 ----
70 /////
71
72 * <!ViewGitFile(mlton,master,ide/enscript/sml_gaudy.st)> -- Supersedes the
73 above, adding highlighting of type annotations, in both expressions
74 and signatures. Due to the limited parsing available, it is assumed
75 that the input is a syntactically correct, top-level declaration.
76 /////
77 +
78 [source,sml]
79 ----
80 signature S = sig
81 type t
82 val x : t
83 val f : t * int -> int
84 end
85 structure S : S = struct
86 datatype t = T of int
87 val x : t = T 0
88 fun f (T x, i : int) : int = x + y
89 fun 'a id (x: 'a) : 'a = x
90 end
91 ----
92 /////
93
94 == Install and use ==
95
96 * Version 1.6.3 of http://people.ssh.com/mtr/genscript[GNU Enscript]
97 ** Copy all files to `/usr/share/enscript/hl/` or `.enscript/` in your home directory.
98 ** Invoke `enscript` with `--highlight=sml_simple` (or `--highlight=sml_verbose` or `--highlight=sml_fancy` or `--highlight=sml_gaudy`).
99
100 * Version 1.6.1 of http://people.ssh.com/mtr/genscript[GNU Enscript]
101 ** Append <!ViewGitFile(mlton,master,ide/enscript/sml_all.st)> to `/usr/share/enscript/enscript.st`
102 ** Invoke `enscript` with `--pretty-print=sml_simple` (or `--pretty-print=sml_verbose` or `--pretty-print=sml_fancy` or `--pretty-print=sml_gaudy`).
103
104 == Feedback ==
105
106 Comments and suggestions should be directed to <:MatthewFluet:>.