A quick tutorial: How to use the Colorer-take5 (from now on, simply C5) library to implement syntax colouring with eclipse to new language. This tutorial uses P-Cube’s SML language as an example, and was written by Ron Mertens (email@example.com).
The plug-in can be installed automatically using Eclipse’s update manager. Point the manager to http://colorer.sf.net/eclipsecolorer/ And install the plug-in.
The HRC is a ‘language’ used to describe languages in C5, and is based on XML formats. We will use two HRC files – one is the ‘main’ one, that contains language prototypes declarations. The other one is a detailed HRC, used to describe a language.If you installed the plug-in in c:\eclipse, for example, the C5 main HRC file is located in – C:\eclipse\plugins\net.sf.colorer_0.6.0\colorer\hrc\colorer.hrc If you open this file, you’ll notice a list of prototypes of languages, such as C, Pascal, java and ADA. You’ll have to insert the prototype of your language here. Let’s view the P-Cube SML prototype –
<prototype name="PSML" group="rare" description="P-Cube SML">This is pretty straightforward, but we’ll explain it anyway –
<param name="P-Cube SML packages" value="true" description="P-Cube SML packages (P-Cube INC)."/>
P-Cube SML is somewhat similar to java. We based our HRC file on java’s language, so we didn’t need to write everything from scratch.
All the internal HRC files in the C5 library are in the common.jar file, located in the same directory as the colorer.hrc file. Jar files are simply zip files, so you can open them, and extract the java.hrc file. In our example we renamed it to sml.hrc.
We will not go into detail on how to edit those files here. It is pretty straightforward – this files include keyword for syntax colouring, and stuff like that.
The last stage is to tell eclipse to open files using this plug-in. In eclipse preferences, under workspace, you can set file association (Window/Preferences/Workbench/File Associations). In our example, we have set up eclipse to use the Color5 editor when opening .san and .swip file.