Depending on their scope, there are three kinds of rules:
In practice only terminal rules are different. These are stored in Python modules, and so are static, while the other rules are generated dynamically from configuration files.
Except for terminal rules, all rules are an aggregation of smaller rules, creating a small tree.
These trees are read in pre-order.
The following example is a generic rules tree:
Rules nodes will be substituted by the rules they contain.
Note that the rule in the second level has a loop. This means that the rules it contains may appear multiple times.
As trees are read in pre-order, this would read as:
“Rule composed of terminal rule 1, followed by terminal rule 2, followed by terminal rule 4 multiple times, followed by terminal rule 3, followed by terminal rule 1.”