Child pages
  • KeywordRegex

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Code Block
| KeywordRegex = "keyword" "regex"  MatchTokens=RegexExpression "rule" QualifiedName ";";

KeywordRegex lets you specify the regular expression that describes language keywords and  the rule name that will substitute a whitespace rule during an automatic whitespace rule placement.

The inserted rule should verify that the characters following the keyword are not parts of identifiers. Otherwise the identifier prefixes that match keywords will be mistakenly parsed (e.g. “do” in doStaff, when “do” is a keyword). For that reason the specified rule should contain a corresponding predicate.

For example, the following definition places the S rule after the literals that consist of lowercase alphabet characters:

Code Block
keyword regex ['a'..'z']+ rule S;

This rule is defined in the Whitespaces module as follows:

Code Block
void S = !IdentifierPartCharacters s; // identifier break spacer

This rule verifies that the current character is not one of the characters allowed in the identifier, next it recognizes the standard whitespace s rule declared in the same module.

If parsing of whitespace character in your language doesn’t follow the standard rules, you can declare your own s and S rules versions.

See also

QualifiedName
RegexExpression
Whitespaces