tags/ozDavid Bremnerby-nc-sa-2.5
Copyright 2020, David Bremner
https://www.cs.unb.ca/~bremner//tags/oz/David Bremnerikiwiki2009-08-08T13:17:24Zsource-highlight and ozhttps://www.cs.unb.ca/~bremner//blog/posts/oz-source-highlight/
<a href="../../whyCC/">by-nc-sa-2.5</a>
Copyright 2020, David Bremner
2009-08-08T13:17:24Z2009-02-03T21:49:00Z
<p>In order to have pretty highlighted <a href="http://www.mozart-oz.org">oz</a>
code in HTML and TeX, I defined a simple language definition "oz.lang"</p>
<div class="highlight-txt"><pre class="hl">keyword = "andthen|at|attr|case|catch|choice|class|cond",
"declare|define|dis|div|do|else|elsecase|",
"elseif|elseof|end|fail|false|feat|finally|for",
"from|fun|functor|if|import|in|local|lock|meth",
"mod|not|of|or|orelse|prepare|proc|prop|raise",
"require|self|skip|then|thread|true|try|unit"
meta delim "<" ">"
cbracket = "{|}"
comment start "%"
symbol = "~","*","(",")","-","+","=","[","]","#",":",
",",".","/","?","&","<",">","\|"
atom delim "'" "'" escape "\\"
atom = '[a-z][[:alpha:][:digit:]]*'
variable delim "`" "`" escape "\\"
variable = '[A-Z][[:alpha:][:digit:]]*'
string delim "\"" "\"" escape "\\"
</pre></div>
<p>The meta tags are so I can intersperse EBNF notation in with oz code.
Unfortunately source-highlight seems a little braindead about e.g. environment variables, so I had to wrap the invocation in a script</p>
<div class="highlight-sh"><pre class="hl"><span class="hl slc">#!/bin/sh</span>
HLDIR<span class="hl opt">=</span><span class="hl kwd">$HOME</span><span class="hl opt">/</span>config<span class="hl opt">/</span><span class="hl kwb">source-highlight</span>
<span class="hl kwb">source-highlight --style-file</span><span class="hl opt">=</span><span class="hl kwd">$HLDIR</span><span class="hl opt">/</span>default.style <span class="hl kwb">--lang-map</span><span class="hl opt">=</span><span class="hl kwd">$HLDIR</span><span class="hl opt">/</span>lang.map $<span class="hl opt">*</span>
</pre></div>
<p>The final pieces of the puzzle is a customized <a href="https://www.cs.unb.ca/~bremner//blog/files/lang.map">lang.map</a> file
that tells source-highlight to use "oz.lang" for "foo.oz" and a
<a href="https://www.cs.unb.ca/~bremner//blog/files/default.style">default.style</a> file that defines highlighting for "meta"
text.</p>
<p><strong>UPDATED</strong> An improved version of this lang file is now in
source-highlight, so this hackery is now officially obsolete.</p>