Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 9406df6f885a8f97005c2d7e241d165f > files > 422

colorer-take5-docs-0-0.beta5.14.mga7.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META
 name="DC.Title"
 content="A quick tutorial  How to use the Color5 library to implement s" >
<META
 name="DC.Contributor"
 content="Ron Mertens" >
<META
 name="DC.Date"
 content="2004-03-18T08:28:52+02:00" >
<META
 name="DC.Date.Modified"
 content="2004-03-18T09:53:21+03:00" >
<link rel="stylesheet" type="text/css" href="../styles/styles.css"/>
<link rel="icon" href="../images/logo-small.png"/>
</HEAD>
<BODY>

<P>
A quick tutorial: How to use the Colorer-take5 (from now on, simply C5) library
to implement syntax colouring with eclipse to new language.
<I>This tutorial uses P-Cube&rsquo;s SML language as an example,
and was written by Ron Mertens (ronm@p-cube.com</I>).
</P>

<H1>Install the C5 eclipse plug-in</H1>

<P>
The plug-in can be installed automatically using Eclipse&rsquo;s update manager. Point the manager to

http://colorer.sf.net/eclipsecolorer/ And install the plug-in.

<H1>Add the P-Cube SML prototype to the Color5 main HRC file </H1>

<P>The HRC is a &lsquo;language&rsquo; used to describe languages in C5,
and is based on XML formats. We will use two HRC files &ndash; one is the
&lsquo;main&rsquo; one, that contains language prototypes declarations.
The other one is a detailed HRC, used to describe a language.
</P>

If you installed the plug-in in c:\eclipse, for example, the C5 main HRC file is located in &ndash; 

C:\eclipse\plugins\net.sf.colorer_0.6.0\colorer\hrc\colorer.hrc

If you open this file, you&rsquo;ll notice a list of prototypes of languages,
such as C, Pascal, java and ADA. You&rsquo;ll have to insert the prototype of
your language here. Let&rsquo;s view the P-Cube SML prototype &ndash;

<pre>
<FONT color="#A65600"><<FONT color="#7F0000"><B>prototyp<FONT  color="#7F0000"><B>e <FONT color="#064625"></B>name<FONT color="#7F7F2F">=<FONT color="#0000E6">"PSML" <FONT color="#064625">group<FONT color="#7F7F2F">=<FONT color="#0000E6">"rare" <FONT color="#064625">description<FONT color="#7F7F2F">=<FONT color="#0000E6">"P-Cube SML"<FONT color="#A65600"></B>>
</P><P><FONT color="#A65600"><<FONT color="#7F0000"><B>locatio<FONT color="#7F0000"><B>n <FONT color="#064625"></B>link<FONT color="#7F7F2F">=<FONT color="#0000E6">"sml/sml.hrc"<FONT color="#A65600">/<FONT color="#A65600"></B>>
</P><P><<FONT color="#7F0000"><B>filename<FONT color="#A65600"></B>><FONT color="#7F0000">/<FONT color="#0E68FF">\.<FONT color="#7F7F2F">(<FONT color="#000000">san<FONT color="#7F007F">|<FONT color="#000000">swip<FONT color="#7F7F2F">)$<FONT color="#7F0000">/<B>i<FONT color="#A65600"></B></<FONT color="#7F0000"><B>filename>
</P><FONT color="#A65600"></B><<FONT color="#7F0000"><B>parameters>
<P><FONT color="#A65600"></B><<FONT color="#7F0000"><B>para<FONT color="#7F0000"><B>m <FONT color="#064625"></B>name<FONT color="#7F7F2F">=<FONT color="#0000E6">"P-Cube SML packages" <FONT color="#064625">value<FONT color="#7F7F2F">=<FONT color="#0000E6">"true<FONT color="#0000E6"></B>"
        <FONT color="#064625">description<FONT color="#7F7F2F">=<FONT color="#0000E6">"P-Cube SML packages (P-Cube INC)."<FONT color="#A65600">/<FONT color="#A65600">>
</P><P><B>&lt;/<FONT color="#7F0000">parameters>
<FONT color="#A65600">&lt;/</FONT><FONT color="#7F0000">prototype></FONT></B>

</pre>

<FONT color="#000000">
This is pretty straightforward, but we&rsquo;ll explain it anyway &ndash; </P>
<OL type="1">
<LI>Prototype tag. Includes the language&rsquo;s name, the group (rare, main, etc.) and description. </P></LI>
<LI>Location &ndash; this is the location of your detailed HRC file. The next section
describes how to create this file.
</P></LI>
<LI>The filename is important &ndash; this example shows that any file with
a .san or.swip extension is part of the P-Cube SML language. </P></LI></OL>

</DIV></DIV></DIV>

<DIV class="Part">

<H1>Prepare your detailed HRC file</H1>

<P>
P-Cube SML is somewhat similar to java. We based our HRC file on java&rsquo;s language, so we didn&rsquo;t need to write everything from scratch. </P
><P 

>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. </P
><P 

>We will not go into detail on how to edit those files here. It is pretty straightforward &ndash; this files include keyword for syntax colouring, and stuff like that. </P
></DIV
><DIV class="Part" 

>
<H1>Associate your files with the color5 plug-in</H1>

<P>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. </P
></DIV>

<DIV class="Part">

<H1>That&rsquo;s it!</H1> 

Eclipse is now ready to use the Color5 plug-in to display your language, and syntax-colour it. Not very complicated once you know how to do it.

<H1>More information</H1>

<a href="http://colorer.sf.net">The C5 homepage</a><br/>
<a href="http://www.eclipse.org">Eclipse organization homepage</a><br/>
<a href="http://www.p-cube.com">P-Cube Inc</a><br/>

Enjoy, <br/>
Ron M.<br/>
P-Cube Inc, http://www.p-cube.com<br/>

</BODY>
</HTML>