Keyword directives colorization:keyword directives – Crunch CRiSP File Editor 6 User Manual

Page 74

Advertising
background image

Page 74

char_backslash=

This class is used to redefined the backslash character. In many languages, backslash character is
used to turn off (or escape) the meaning of the following character. For example in a shell script or
the C language, this mechanism allows you to embed a quote inside a string, which would
otherwise normally terminate the string.

Whether your language will use backslashes or not is handled by specifying the
accept_backslashes keyword prefix, e.g. so that backslashes are handled in a context sensitive
manner.

You should use this sequence only if you want to use an alternate character other than the
backslash to have this meaning. If you do use this character class, then the backslash will lose its
normal meaning, and if you want to maintain the backslash then ensure you add it to the character
class.

Keyword Directives

Colorization:keyword directives

CRiSP supports for coloring comments, strings,

numbers, reserved words and other artefacts of a file. The general term used to describe these entities is a
keyword. When looked at closely, the only difference between these token classes is simply the default
color in which the tokens are displayed.

Because all these user definable types are the same, the mechanism to describe them is the same; the only
difference is the directive used in the .kwd file to define the class of the keyword, and thus affect the
coloring.

The following classes of keywords are available:

string used for things that looks like string constants or literals.

comment used for comments. Comments can be multi-line or extend to the end of a line.

keyword used for keywords and reserved words in the language.

directive a special context sensitive type of keyword construct, e.g. the directives used in the C
preprocessor are a good example.

symbol1, symbol2, symbol3, and symbol4. These are spare classes which you can use for other
categories of syntax elements, where the existing categories are insufficient. For example, in SQL,
symbol1 and symbol2 are used to color global and local variables. (This is doable in SQL,
because the syntax of a variable allows you to determine its scope; it is not possible in C, for
example, because a semantic analysis of the file would be necessary to determine the storage
class of a variable).

The format of a directive line is exemplified by the following:

directive="^[ \t]*#*"

comment=accept_backslashes "//*.*$"
comment="/**.**/"

string=accept_backslashes "\"*.*\""
string=accept_backslashes "'*.*'"

/*******************************/
/* C keywords. */
/*******************************/
keyword="asm" "auto" "break" "case"
keyword="char" "const" "continue"

There are a number of things to note about these definitions:

A directive starts on a line with one of the keywords directive=, comment=, string=, keyword=,
symbol1=, symbol2=, symbol3=
or symbol4=.

Advertising