<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="robots" content="index,nofollow">



<title>Enscript - MLton Standard ML Compiler (SML Compiler)</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="print.css">


<link rel="Start" href="Home">


</head>

<body lang="en" dir="ltr">

<table bgcolor = lightblue cellspacing = 0 style = "border: 0px;" width = 100%>
  <tr>
    <td style = "
		border: 0px;
		color: darkblue; 
		font-size: 150%;
		text-align: left;">
      <a class = mltona href="Home">MLton 20051202</a>
    <td style = "
		border: 0px;
		font-size: 150%;
		text-align: center;
		width: 50%;">
      Enscript
    <td style = "
		border: 0px;
		text-align: right;">
      <table cellspacing = 0 style = "border: 0px">
        <tr style = "vertical-align: middle;">
      </table>
  <tr style = "background-color: white;">
    <td colspan = 3
	style = "
		border: 0px;
		font-size:70%;
		text-align: right;">
      <a href = "Home">Home</a>
      &nbsp;<a href = "Index">Index</a>
      &nbsp;
</table>
<div id="content" lang="en" dir="ltr">
<a class="external" href="http://people.ssh.com/mtr/genscript"><img src="moin-www.png" alt="[WWW]" height="11" width="11">GNU Enscript</a> converts ASCII files to PostScript, HTML, and other output languages,  applying language sensitive highlighting (similar to <a href="Emacs">Emacs</a>'s font lock mode).  Here are a few <em>states</em> files for highlighting <a href="StandardML"> Standard ML</a>. 
    <ul>

    <li>
<p>
 
<a href = "http://mlton.org/cgi-bin/viewsvn.cgi/mlton/tags/on-20051202-release/ide/enscript/sml_simple.st?view=markup"><img src="moin-www.png" alt="[WWW]" height="11" width="11">sml_simple.st</a>
 -- Provides highlighting of keywords, string and character constants, and (nested) comments.  
<pre class=code>
<I><FONT COLOR="#B22222">(* Comments (* can be nested *) *)</FONT></I>
<B><FONT COLOR="#A020F0">structure</FONT></B> S = <B><FONT COLOR="#A020F0">struct</FONT></B>
  <B><FONT COLOR="#A020F0">val</FONT></B> x = (1, 2, <FONT COLOR="#BC8F8F"><B>&quot;three&quot;</FONT></B>)
<B><FONT COLOR="#A020F0">end</FONT></B>
</PRE>
 
</p>
</li>
    <li class="gap">
<p>
 
<a href = "http://mlton.org/cgi-bin/viewsvn.cgi/mlton/tags/on-20051202-release/ide/enscript/sml_verbose.st?view=markup"><img src="moin-www.png" alt="[WWW]" height="11" width="11">sml_verbose.st</a>
 -- Supersedes the above, adding  highlighting of numeric constants.  Due to the limited parsing  available, numeric record labels are highlighted as numeric  constants, in all contexts.  Likewise, a binding precedence separated  from <tt>infix</tt> or <tt>infixr</tt> by a newline is highlighted as a  numeric constant and a numeric record label selector separated from  <tt>#</tt> by a newline is highlighted as a numeric constant.  
</p>
 
<pre class=code>
<B><FONT COLOR="#A020F0">structure</FONT></B> S = <B><FONT COLOR="#A020F0">struct</FONT></B>
  <I><FONT COLOR="#B22222">(* These look good *)</FONT></I>
  <B><FONT COLOR="#A020F0">val</FONT></B> x = (<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <FONT COLOR="#BC8F8F"><B>&quot;three&quot;</FONT></B>)
  <B><FONT COLOR="#A020F0">val</FONT></B> z = #2 x

  <I><FONT COLOR="#B22222">(* Although these look bad (not all the numbers are constants),       *
   * they never occur in practice, as they are equivalent to the above. *)</FONT></I>
  <B><FONT COLOR="#A020F0">val</FONT></B> x = {<B><FONT COLOR="#5F9EA0">1</FONT></B> = <B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B> = <FONT COLOR="#BC8F8F"><B>&quot;three&quot;</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B> = <B><FONT COLOR="#5F9EA0">2</FONT></B>}
  <B><FONT COLOR="#A020F0">val</FONT></B> z = #
            <B><FONT COLOR="#5F9EA0">2</FONT></B> x
<B><FONT COLOR="#A020F0">end</FONT></B>
</PRE>
<p>
 
</p>
</li>
    <li class="gap">
<p>
 
<a href = "http://mlton.org/cgi-bin/viewsvn.cgi/mlton/tags/on-20051202-release/ide/enscript/sml_fancy.st?view=markup"><img src="moin-www.png" alt="[WWW]" height="11" width="11">sml_fancy.st</a>
 -- Supersedes the above, adding  highlighting of type and constructor bindings, highlighting of  explicit binding of type variables at <tt>val</tt> and <tt>fun</tt> declarations, and  separate highlighting of core and modules level keywords.  Due to the  limited parsing available, it is assumed that the input is a  syntactically correct, top-level declaration.  
<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = <B><FONT COLOR="#0000FF">struct</FONT></B>
  <B><FONT COLOR="#A020F0">val</FONT></B> x = (<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <FONT COLOR="#BC8F8F"><B>&quot;three&quot;</FONT></B>)
  <B><FONT COLOR="#A020F0">datatype</FONT></B><FONT COLOR="#228B22"><B> 'a t </FONT></B>=<FONT COLOR="#228B22"><B> <FONT COLOR="#B8860B">T</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> 'a
       </FONT></B><B><FONT COLOR="#A020F0">and</FONT></B><FONT COLOR="#228B22"><B> u </FONT></B>=<FONT COLOR="#228B22"><B> <FONT COLOR="#B8860B">U</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> v * v
  </FONT></B><B><FONT COLOR="#A020F0">withtype</FONT></B><FONT COLOR="#228B22"><B> v </FONT></B>=<FONT COLOR="#228B22"><B> {left: int t, right: int t}
  </FONT></B><B><FONT COLOR="#A020F0">exception</FONT></B><FONT COLOR="#228B22"><B> <FONT COLOR="#B8860B">E1</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int </FONT></B><B><FONT COLOR="#A020F0">and</FONT></B><FONT COLOR="#228B22"><B> <FONT COLOR="#B8860B">E2</FONT>
  </FONT></B><B><FONT COLOR="#A020F0">fun</FONT></B> <FONT COLOR="#228B22"><B>'a</FONT></B> id (x: 'a) : 'a = x

  <I><FONT COLOR="#B22222">(* Although this looks bad (the explicitly bound type variable 'a is *
   * not highlighted), it is unlikely to occur in practice.            *)</FONT></I>
  <B><FONT COLOR="#A020F0">val</FONT></B> 
      'a id = <B><FONT COLOR="#A020F0">fn</FONT></B> (x : 'a) =&gt; x
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
 
</p>
</li>
    <li class="gap">
<p>
 
<a href = "http://mlton.org/cgi-bin/viewsvn.cgi/mlton/tags/on-20051202-release/ide/enscript/sml_gaudy.st?view=markup"><img src="moin-www.png" alt="[WWW]" height="11" width="11">sml_gaudy.st</a>
 -- Supersedes the above, adding  highlighting of type annotations, in both expressions and signatures.  Due to the limited parsing available, it is assumed that the input is  a syntactically correct, top-level declaration.   
<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> S = <B><FONT COLOR="#0000FF">sig</FONT></B>
  <B><FONT COLOR="#A020F0">type</FONT></B><FONT COLOR="#228B22"><B> t
  </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> x :<FONT COLOR="#228B22"><B> t
  </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> f :<FONT COLOR="#228B22"><B> t * int -&gt; int
</FONT></B><B><FONT COLOR="#0000FF">end</FONT></B>
<B><FONT COLOR="#0000FF">structure</FONT></B> S : S = <B><FONT COLOR="#0000FF">struct</FONT></B>
  <B><FONT COLOR="#A020F0">datatype</FONT></B><FONT COLOR="#228B22"><B> t </FONT></B>=<FONT COLOR="#228B22"><B> <FONT COLOR="#B8860B">T</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> int
  </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> x :<FONT COLOR="#228B22"><B> t </FONT></B>=<FONT COLOR="#228B22"><B></FONT></B> T <B><FONT COLOR="#5F9EA0">0</FONT></B>
  <B><FONT COLOR="#A020F0">fun</FONT></B> f (T x, i :<FONT COLOR="#228B22"><B> int</FONT></B>) :<FONT COLOR="#228B22"><B> int </FONT></B>=<FONT COLOR="#228B22"><B></FONT></B> x + y
  <B><FONT COLOR="#A020F0">fun</FONT></B> <FONT COLOR="#228B22"><B>'a</FONT></B> id (x:<FONT COLOR="#228B22"><B> 'a</FONT></B>) :<FONT COLOR="#228B22"><B> 'a </FONT></B>=<FONT COLOR="#228B22"><B></FONT></B> x
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
 
</p>
</li>

    </ul>


<h2 id="head-e5a1ef08918738578c7f1b88920c73a60499c69d">Install and use</h2>

    <ul>

    <li>
<p>
 Version 1.6.3 of <a class="external" href="http://people.ssh.com/mtr/genscript"><img src="moin-www.png" alt="[WWW]" height="11" width="11">GNU Enscript</a> 
</p>
</li>

            <ul>

            <li>
<p>
 Copy all files to <tt>/usr/share/enscript/hl/</tt> or <tt>.enscript/</tt> in your home directory. 
</p>
</li>
            <li>
<p>
 Invoke <tt>enscript</tt> with <tt>--highlight=sml_simple</tt> (or <tt>--highlight=sml_verbose</tt> or <tt>--highlight=sml_fancy</tt> or <tt>--highlight=sml_gaudy</tt>). 
</p>
</li>

            </ul>


    <li>
<p>
 Version 1.6.1 of <a class="external" href="http://people.ssh.com/mtr/genscript"><img src="moin-www.png" alt="[WWW]" height="11" width="11">GNU Enscript</a> 
</p>
</li>

            <ul>

            <li>
<p>
 Append 
<a href = "http://mlton.org/cgi-bin/viewsvn.cgi/mlton/tags/on-20051202-release/ide/enscript/sml_all.st?view=markup"><img src="moin-www.png" alt="[WWW]" height="11" width="11">sml_all.st</a>
 to <tt>/usr/share/enscript/enscript.st</tt> 
</p>
</li>
            <li>
<p>
 Invoke <tt>enscript</tt> with <tt>--pretty-print=sml_simple</tt> (or <tt>--pretty-print=sml_verbose</tt> or <tt>--pretty-print=sml_fancy</tt> or <tt>--pretty-print=sml_gaudy</tt>). 
</p>
</li>

            </ul>



    </ul>


<p>
This <a href="WebSite">WebSite</a> uses <tt>sml_fancy</tt> to pretty-print <a href="StandardML">Standard ML</a> source code.  Comments and suggestions should be directed to <a href="MatthewFluet">MatthewFluet</a>. 
</p>
</div>



<p>
<hr>
Last edited on 2005-12-02 03:28:59 by <span title="ppp-71-139-183-221.dsl.snfc21.pacbell.net"><a href="StephenWeeks">StephenWeeks</a></span>.
</body></html>
