Crunch CRiSP File Editor 6 User Manual

Page 73

Advertising
background image

Page 73

Defines the characters which can form the 2nd and subsequent characters in a keyword or variable
name. This may be different from the char_start field.

For example in C, this is the same as the first character, but also includes the digits: [A-Za-z0-9_].

char_last

Specify this to indicate characters which are a valid part of a keyword or variable name. Whereas
char_start and char_next specify characters which form part of the name, char_last also
specifies that any of these characters terminate the name.

For example, consider a Bourne shell script. In the script language, you can define variables, and
they are usually specified with a preceding dollar $ character. The syntax for Bourne shell is
peculiar in that you can create arbitrary variables using this syntax, but there are certain variables
built into the language. For example, $$ is the current process id. In this case, a subsequent $ is to
be treated as part of the variable name, but also to terminate the name at that point.

An example might be:

char_start="[A-Za-z_$]"
char_next="[A-Za-z0-9$]"
char_last="[$]"

char_new_token

This character class is designed for languages like shell script where there is an ambiguity in the
end of one keyword and the start of the next.

Consider a statement like:

echo $DIR$FILENAME

In this example, after the keyword echo we have two separate variables, $DIR and $FILENAME. If
you look at the char_last description given above, then we see that the above could be parsed as
$DIR$ followed by FILENAME. If we had something like $DIR$echo then the word echo would be
treated as a keyword, and not as a variable.

The char_new_token class tells CRiSP that characters in this class are part of a token, but also
start a new token, even if we are already inside a token. Thus, a more correct definition for a shell
script colorizer would be:

char_start="[A-Za-z_$]
char_next="[A-Za-z0-9$]
char_last="[$]"
char_new_token="[$]"

char_operator=

Use this character class to resolve ambiguities concerning characters which have dual roles in the
language. This is mainly used in C like languages where there is a conflict on the forward slash
character /. A forward slash in C can be used in three or four parts of the language:

I

If followed by an asterisk, then we are at the start of a multi-line comment. If followed by another
slash, (assuming C++ comments), then it is a comment until the end of the line. Otherwise it could
be a divide or divide-eq operator.

CRiSP supports the ability to color operators (generally an operator is something that isn't a
keyword, a number, a comment or a string) in a separate color. Because the slash character is part
of a comment, CRiSP would normally believe a slash to be a valid symbol character. By specifying
a character class for operators helps to avoid mis-coloring a slash which is not the start of a
comment.

Consider the following example:

int x = 3 /sizeof y;

Without the char_operator class definition, because there is no space between the forward slash
and the keyword sizeof, then CRiSP would assume that we had a variable called /sizeof and not
color the keyword as you would expect.

The following is an example of the char_operator directive for the C language:

char_operator="[/*]"

Advertising