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. “
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:
This rule is defined in the
Whitespaces module as follows:
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 rules versions.