UNB/ CS/ David Bremner/ tags/ oz

This feed contains pages with tag "oz".

In order to have pretty highlighted oz code in HTML and TeX, I defined a simple language definition "oz.lang"

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 "\\"

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

#!/bin/sh
HLDIR=$HOME/config/source-highlight
source-highlight --style-file=$HLDIR/default.style --lang-map=$HLDIR/lang.map $*

The final pieces of the puzzle is a customized lang.map file that tells source-highlight to use "oz.lang" for "foo.oz" and a default.style file that defines highlighting for "meta" text.

UPDATED An improved version of this lang file is now in source-highlight, so this hackery is now officially obsolete.

Posted Tue 03 Feb 2009 05:49:00 PM Tags: /tags/oz