Crunch CRiSP File Editor 6 User Manual

Page 72

Advertising
background image

Page 72

spell_text

For most languages, you would not spell check all the types of entities in your files. You would
normally restrict spell checking to things such as comments or quoted literal strings. For those
types of languages you explicitly state (using the spell keyword) that each syntactic item needs
spell checking.

In the case of a language like HTML, you would want to check the raw text but not check any
specific keyword definition; this is almost the direct opposite of other programming language files.
Instead of checking (or as well as) the spelling for comments and keywords, you also want to spell
check the actual text which isn't defined as a specific keyword type. To achieve this, you need to
specify the spell_text keyword in the flags definition. This indicates to CRiSP that the default action
for non-keywords is to spell check.

The HTML colorizer definition (src/keywords/html.kwd) includes this setting as standard.

start_of_line

This flag has no meaning for the flags= directive. It can be used with keyword definitions to indicate
that they are only valid at the start of a line.

x_hexadecimal

Specify this flag if hexadecimal numbers are represented using the notation: X'nnn' where nnn is a
hexadecimal string.

Character Class Directives

Colorization:character classes

CRiSP has a minimal idea of what constitutes a

keyword. If you look at normal plain text, the human brain can easily decipher what constitutes a word, e.g. a
sequence of letters. White space and other punctuation delimits a word.

Consider a language like C. If we applied the same definition then we would end up treating a variable name
like:

pointer_to_list_array_struct

as 5 individual words, with the word struct at the end of the line as a keyword and not a variable.

Different languages have different naming conventions for keywords and variable names. Many are similar
to the C definition, maybe with some slight alteration. In the C language, a variable is a sequence of upper
and lower case letters, digits or the underscore character, with the restriction that variables cannot start with
a digit. (If variables could start with a digit, then we would have problems distinguish a variable from a
number when only looking at the first character).

The keyword description file allows you to define character classes, i.e. sets of characters, which form part
of the syntax of the language.

All of these character class directives start with the prefix char_. A character class definition allows you to
specify the valid characters within certain contexts of the language. CRiSP uses these contexts to resolve
ambiguities it comes across.

Character classes are specified as a regular expression style character class, by enclosing the list of
characters in square brackets. The entire string is specified in string quotes. For example

char_start="[A-Za-z_]"
char_next="[A-Za-z_0-9]"
char_new_token="[/*]"
char_operator="[/*]"

Most languages will use a simple variation on the theme above (the above is for the C language).

char_start

This defines the characters which are start a keyword or variable name. (As far as CRiSP is
concerned, the only difference between a keyword and a variable name is the color it is drawn in).

For example in C, this is the letters and underscore: [A-Za-z_].

char_next

Advertising