Keyword builder – Crunch CRiSP File Editor 6 User Manual
Page 68

Page 68
This is a piece of CRiSP macro code. The CRiSP macro code looks and feels a lot like C. Without
necessarily knowing any of the details of the macro language, you can immediately see that different parts
of the edit window are colored differently. In the sample, comments have a grey background with black text.
These comments act as eye-catchers, and nicely sub-divide long code sequences into regions of interest. It
makes it much more each for the brain to look for patterns in color, rather than looking at the plain boring
text.
It is important to realise that colorization is an inexact process. It relies on context independent information
to guess the type of tokens in your file and color them according to your personal tastes. Having said that
colorization is inexact, it is also important to note that colorization probably works in more than 99% of
typical cases, so the results are actually very satisfying. The reason for highlighting this inexactness, is that
if you decide to create custom keyword files, then you cannot expect to handle every situation which your
files require. There are certain trade-offs involved. These trade-offs are to do with CRiSP's capabilities
versus the ease with which you can create a custom keyword file.
There are two ways to create a colorization file. Using the Keyword Builder(pg. 68). dialog box on the
Options menu, or by hand crafting a .kwd file. The Keyword Builder dialog provides most of the functionality
required to create a custom colorization and is the preferred route. The other sections in this chapter of the
manual provide a complete definition of the facilities available to create a colorization.
It typically takes 5 to 10 minutes to create your own file, which maybe can handle 90% of your colorization
task. This is achievable usually by taking one of the provided keyword files, and customizing it for your own
data file. To get a higher than 90% acceptable colorization may involve reading these sections more
thoroughly to understand what all the options and features are.
CRiSP supports colorization by loading a keyword description file. These files usually have the file extension
of .KWD and the ones CRiSP is supplied with are usually located in /usr/local/crisp/src/keywords or
C:\CRISP\SRC\KEYWORDS for a Windows style installation. These files cover many languages, including
Ada, C, Fortran, Perl, PostScript and Shell script. The differences between one language and any other is
usually very small. If you look at the samples provided the main thing which you will see is the list of
keywords. Other differences result in whether, for instance a language can support numbers in hexadecimal,
or floating point, whether keywords are case sensitive, etc.
Each keyword file contains a description for a certain class of files. You can override any CRiSP keyword
file, by creating your own version of the file and placing it in the personal configuration directory
($CRCONFIG or $HOME/.Crisp).
→
Keyword Builder dialog box(pg. 68).
→
Description of the .kwd keyword file format(pg. 70).
→
The flags= directive(pg. 71).
→
Character class directives(pg. 72).
→
Keyword directives(pg. 74).
→
Keyword flags(pg. 75).
→
Keyword regular expressions(pg. 76).
→
Limitations of Colorization(pg. 76).
→
Case study #1: The C Colorizer(pg. 77).
→
Case study #2: The Fortran Colorizer(pg. 78).
Keyword Builder
The keyword builder is a dialog which allows you to create and modify colorization definitions. A colorizer