Thursday, December 04, 2008

Syntax Highlight Brush for Erlang

Updated 13-Aug-09 -- use this version instead.

The trailing comma in line 13 is a bug. Remove it.

Following on from yesterday, Erlang;

//WTFPL licensed
dp.sh.Brushes.Erlang = function()
{
 var keywords = 'after begin case catch cond end fun if let of query receive when '+
  'define record export import include include_lib ifdef ifndef else endif undef '+
  'apply attribute call do in letrec module primop try';

 this.regexList = [
  { regex: new RegExp('%.*$', 'gm'),    css: 'comment' },   // one line comments
  { regex: dp.sh.RegexLib.DoubleQuotedString,     css: 'string' },   // strings
  { regex: new RegExp(this.GetKeywords(keywords), 'g'),  css: 'keyword' },  // Erlang keyword
  { regex: new RegExp('_?[A-Z]\\w*', 'g'), css: 'values'},
  { regex: new RegExp('\\w+/\\d+', 'g'), css: 'funs'},
  ];

 this.CssClass = 'dp-erl';
 this.Style = '.dp-erl .values { color: #c88; font-weight: bold;} '+
  '.dp-erl .funs { color: #f00; } ';
}

dp.sh.Brushes.Erlang.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.Erlang.Aliases = ['erlang', 'erl'];

In action here.

Post a Comment