Highlight Detection Rules
Prev
Next

Highlight Detection Rules

This section describes the syntax detection rules.

Each rule can match zero or more characters at the beginning of the string they are asked to test. If the rule matches, the matching characters are assigned the style or attribute defined by the rule, and a rule may ask that the current context is switched.

The attribute and context attributes are common to all rules.

A rule looks like this:

<RuleName attribute="(identifier)" context="(identifier|order)" [rule specific attributes] />

The attribute identifies the style to use for matched characters by name or index, and the context identifies the context to use from here.

The attribute can be identified either by name, or by its zero-based index in the ItemDatas group.

The context can be identified by:

Some rules can have child rules which are then evaluated if and only if the parent rule matched. The entire matched string will be given the attribute defined by the parent rule. A rule with child rules looks like this:

<RuleName (attributes)>
  <ChildRuleName (attributes) />
  ...
</RuleName>

Rule specific attributes varies and are described in the following list.

The Rules in Detail

DetectChar

Detect a single specific character. Commonly used for example to find the ends of quoted strings.

<DetectChar char="(character)" (common attributes) />

The char attribute defines the character to match.

Detect2Chars

Detect two specific characters in a defined order.

<Detect2Chars char="(character)" char1="(character)" (common attributes) />

The char attribute defines the first character to match, char1 the second.

AnyChar

Detect one character of a set of specified characters.

<AnyChar String="(string)" (common attributes) />

The String attribute defines the set of characters.

StringDetect

Detect an exact string.

<StringDetect String="(string)" [insensitive="TRUE|FALSE;"] (common attributes) />

The String attribute defines the string to match. The insensitive attribute defaults to FALSE and is fed to the string comparison function. If the value is TRUE insensitive comparing is used.

RegExpr

Matches against a regular expression.

<RegExpr String="(string)" [insensitive="TRUE|FALSE;"] [minimal="TRUE|FALSE"] (common attributes) />

The String attribute defines the regular expression.

insensitive defaults to FALSE and is fed to the regular expression engine.

minimal defaults to FALSE and is fed to the regular expression engine.

Because the rules are always matched against the beginning of the current string, a regular expression starting with a caret (^) indicates that the rule should only be matched against the start of a line.

See Regular Expressions for more information on those.

Keyword

Detect a keyword from a specified list.

<keyword String="(list name)" (common attributes) />

The String attribute identifies the keyword list by name. A list with that name must exist.

Int

Detect an integer number.

<Int (common attributes) />

This rule has no specific attributes. Child rules are typically used to detect combinations of L and U after the number, indicating the integer type in program code.

Float

Detect a floating point number.

<Float (common attributes)
/>

This rule has no specific attributes.

HlCOct

Detect an octal point number representation.

<HlCOct (common attributes) />

This rule has no specific attributes.

HlCHex

Detect a hexadecimal number representation.

<Int (common attributes) />

This rule has no specific attributes.

HlCStringChar

Detect an escaped character.

<HlCStringChar (common attributes)
/>

This rule has no specific attributes.

It matches letteral representations of invisible characters commonly used in program code, for example \n (newline) or \t (TAB).

The following characters will match if they follow a backslash (\): abefnrtv"'?. Additionally, escaped hexadecimal numbers like for example \xff and escaped octal numbers, for example \033 will match.

RangeDetect

Detect a string with defined start and end characters.

<RangeDetect char="(character)"  char1="(character)" (common attributes) />

char defines the character starting the range, char2 the character ending the range.

Usefull to detect for example small quoted strings and the like, but note that since the hl engine works on one line at a time, this will not find strings spanning over a line break.

LineContinue

Matches at end of line.

<LineContinue (common attributes) />

This rule has no specific attributes.

This rule is useful for switching context at end of line.

Prev
Next
Home