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