quote from wikipedia:
The Rules is a sequence of pair of strings, usually presented in the form of pattern → replacement. Each rule may be either ordinary or terminating.
Given an input string:
- Check the Rules in order from top to bottom to see whether any of the patterns can be found in the input string.
- If none is found, the algorithm stops.
- If one (or more) is found, use the first of them to replace the leftmost occurrence of matched text in the input string with its replacement. If the rule just applied was a terminating one, the algorithm stops.
- Go to step 1.
Note that after each rule application the search starts over from the first rule.
pattern:replacement | This is ordinary rule. Replace first occurrence of pattern to replacement. |
pattern::replacement | This is terminating rule. Replace first occurrence of pattern to replacement and the algorithm stops. |
empty pattern | Empty string matches to the beginning of a string. |
comments | Lines not containing : are regarded as comments. |
spaces | Leading/trailing spaces in pattern/replacement are ignored. |
step limit | The number of replacements must not 50000 times. |
string length limit | The length of input string must not exceed 500 at any moment. |
code length limit | The length of the code must not exceed 1000 including comments and blanks. |