C-- source highlighting using source-highlight

Johan Tibell johan.tibell at gmail.com
Thu Apr 14 17:04:10 CEST 2011


Hi,

I've thrown together a small source-highlight language file for C--.
You can use it to e.g. highlight C-- code when piped through less.

### Installion ###

# This works on Debian/Ubuntu
$ sudo apt-get install source-highlight

# Put this file anywhere
$ cat $HOME/cmm.lang
comment start "//"

# multi-line comments
comment delim "/*" "*/" multiline

string delim "\"" "\"" escape "\\"

keyword = "aborts|align|aligned|also|as|big|bits|byteorder|case|const",
  "continuation|cut|cuts|else|equal|export|foreign|goto|if|import|in",
  "invariant|invisible|jump|little|memsize|pragma|reads|register",
  "return|returns|section|semi|span|stackdata|switch|target|targets|to",
  "typedef|unicode|unwinds|writes"

number =
'\<[+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\.)?
[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(?:8|16|32|64))|L)?\>'

### Usage ###

$ ghc <source> -ddump-cmm | source-highlight --lang-def=$HOME/cmm.lang
-f esc -s cmm | less -R

Johan



More information about the Glasgow-haskell-users mailing list