# Keyword Rules

Keyword rules modify a list of keywords by adding new keywords or removing existing keywords.

The rule consists of a comma-separated list of operators and keywords. In the most simple case, the list is a simple list of keywords that are added to the keyword list.

In addition to adding keywords, keywords may also be removed or replaced with other keywords. To do this, a special prefix character (operator) may be used before each keyword, as shown in the table below:

`+keyword` | Add keyword to the keyword list if it does not already exist. The`+` character is always optional.
`-keyword` | Remove keyword from the keyword list, if it exists.
`-*` | Remove all keywords from the keyword list (delete the entire list).
`?expression` | If expression is true, continue executing the rest of the list. Otherwise, ignore the rest of the list.
`!expression` | If expression is false, continue executing the rest of the list. Otherwise, ignore the rest of the list.
`=keyword` | Delete the last found keyword (that follows a `?`), and replace it with keyword. This may only be used if a single keyword follows the `?`.

Remember, even with these special prefix operators, the list is still a comma separated list and each keyword (or expression) in the list may be preceeded with one of these operators.

Examples:

1. | `-stone` | Delete the keyword "stone" from the keyword list (if it exists).
2. | `?stone,-stone,+rock` | Replace the keyword "stone" with "rock" in the keyword list.
3. | `?stone,=rock` | Replace the keyword "stone" with "rock" in the keyword list. (same as Example 2)
4. | `?stone,+rock,-liquid` | If the keyword list contains the keyword "stone", add the keyword "rock", and delete the keyword "liquid" (if it exists). Don't modify the keyword list if it does not contain the keyword "stone".
5. | `?"b&w",-color` | If the keyword list contains the keyword "b&w" then delete the keyword "color" from the list (if it exists). "b&w" must be in quotes since "&" is an operator.
6. | `?color,-b&w` | If the keyword list contains the keyword "color" then delete the keyword "b&w" from the list (if it exists). "b&w" must not be in quotes since it is not an expression.
7. | `!*,+empty` | Add the keyword "empty" to the list if it doesn't contain any keywords.
8. | `?one|two|three,+number` | Add the keyword "number" to the list if it contains the keyword "one", "two", or "three" (any or all).
9. | `?*&!sorted,+unsorted` | Add the keyword "unsorted" to the list if it already contains at least one keyword but does not contain the keyword "sorted".
10. | `?(1&one)|(3&three),double,odd` | Add the keywords "double" and "odd" to the list if it contains both "1" and "one", or both "3" and "three".

Table of Contents