JSSC 是一款不错的由国人开发的前台代码加亮工具,他的特点是将加亮处理放在了Flash文件中(由ActionScript驱动,虽然是脚本语言,但也是编译后才执行的,在Flash Player中),这也就是相对于其他前台加亮工具效率高一些的原因(具体数据未测).
    当然,这也是在JSSC4以后的版本中才有的.于是我们有了两个版本的拓展方法.

    JSSC 在 第三版本中,还是由JavaScript脚本文件作为加亮库驱动,其中因载入方法不同而分为全载入,分类载入以及自动载入,但其加亮库还是一样的,所以就以自动载入为例子,在JSSC3 自动载入文件夹下(Jssc3/Auto-Load/)可以看到很多由语言名命名的文件.都是经过压缩的,我们可以进入 Jssc3/Uncompressed/ 文件夹下查看相同文件,这些都是未经过加密的.比如 javascript.js 文件.

jssc.oSyntaxList.javascript = {
	title: "JavaScript", //语言名称
	aliases: ['javascript', 'js', 'jscript'], //加亮关键字 即pre加亮段中语言标识
	keyWords: " abstract boolean byte class const debugger delete " +
		"enum export extends final finally goto implements import " +
		"in instanceof interface native new package private protected " +
		"public super synchronized this throw throws transient try " +
		"typeof var volatile with document window " + jssc.sCTypeKeyWords, //关键字, 可以在这里加入自己所需要语言的关键字
	regLib: [
		{ index: '//', reg: new RegExp('^//.*$'), css: "comment" }, //注释的样式
		{ index: '/*', end: '*/', css: "comment", multiLine: true, escape: false },  //多行注释
		{ index: '"', end: '"', css: "string", multiLine: true, escape: true },  //字符串
		{ index: "'", end: "'", css: "char", multiLine: true, escape: true },  //字符
		{ index: '.', reg: jssc.regDecimal, css: "num" },  //数字
		{ index: '/', reg: jssc.regRegExp, css: "reg" }  //正则
	],
	collapse: { type: 'sign', start: '{', end: '}' }  //代码段
}

    可以看到其命名空间为 jssc.oSyntaxList.javascript (如果能算是命名空间的话,其实也就是object的方法).具体的作用都已经注释了.接下来修改关键字以及加亮标识和语言名称即可.略.JSSC3本身提供多种语言,我觉得基本上是够了.这里就不多说了

    接下来是JSSC4,它将加亮处理放在了AS (ActionScript 下同)端,优势很明显,即经过编译后的AS语言有很好的处理效率.
    但是这也给我们拓展其加亮语言带来了麻烦,我们需要一款Flash编译以及编辑工具,这里我推荐 FlashDevelop .他是一款开源的基于.net Framework 2.0 的Flash编辑工具,并且自带了一款编译工具,很适合从事Flash脚本编程的人.
    下载并解压缩后,目录大致如下:

    其中bin是导出的可用文件,src为原文件,lib为一些图片资源.
    src中可以看出JSSC的实现结构,Main.as为程序入口,实现了一些与JS交互的接口,以及返回一个由 Parser 简单工厂类构造的语法加亮器,然后传入加亮代码进行处理.
    我们既需要拓展继承了LanguageParser 类的子类即可.而LanguageParser 又有markup 模式,normal 模式,以及other 模式.他们主要处理三种不同类别的语系的加亮方式,分别为 与XML,HTML 等文本标记语言杂合的语言加亮 比如 Flex, JSP 等 (准确来说他们不能称之为语言,只能是作为源代码的一种形式) 的加亮处理, 平常的 C, C#, JS, AS, PHP, JAVA 等语言的加亮处理, other 包含其他未知或者是另类的语言处理,比如 CSS 等(或者在pre段未标明加亮语言的处理).

    下面我们以 JavaScriptParser.as 为例子:

package normal {
	import util.*;
	
	public class JavaScriptParser extends NormalParser {
		
		public function JavaScriptParser(tabSize:int, keyColor:String, numColor:String, commColor:String, strColor:String, regColor:String):void {
			super(tabSize);
			
			//是否有自定义加亮颜色
			key = (keyColor == null ? "00f" : parseColor(keyColor)); 
			num = (numColor == null ? "f00" : parseColor(numColor));
			comm = (commColor == null ? "090" : parseColor(commColor));
			str = (strColor == null ? "f0f" : parseColor(strColor));
			reg = (regColor == null ? "999" : parseColor(regColor));
			
			//加亮关键字,每个关键字之间用空格处理
			keyWords = " abstract boolean byte class const debugger delete " +
				"enum export extends final finally goto implements import " +
				"in instanceof interface native new package private protected " +
				"public super synchronized this throw throws transient try " +
				"typeof var volatile with document window ";
			
			//加亮匹配正则
			regLib = [
				{ type: SearchMode.REG_MATCH, index: "//", reg: RegLib.SIGNLE_COMMENT, color: comm }, //注释
				{ type: SearchMode.REG_MATCH, index: ".", reg: RegLib.DECIMAL, color: num }, //数字
				{ type: SearchMode.LINE_SEARCH, index: "/*", end: "*/", escape: false, color: comm }, //多行注释
				{ type: SearchMode.LINE_SEARCH, index: "'", end: "'", escape: true, color: str }, //字符
				{ type: SearchMode.LINE_SEARCH, index: "\"", end: "\"", escape: true, color: str }, //字符串
				{ type: SearchMode.PERL_REG, index: "/", color: reg } //正则
			];
			collapse = SearchMode.COLLAPSE_C; //C语系 加亮模式
		}
	}
}

    注释已经将各个部分的作用说明清楚了,值得注意的是,还要在 Parser构造工厂中将你的语言关键字以及构造添加到switch case 语句中.

    最后编译导出,属于你的加亮工具就产生了.