Pattern matching can be divided among various rules. From the START rule, other rules can be called. Rules that are called can have any or all of these sections: patterns, filters, or actions.

Operators or functions that work with patterns also work with rules. For example, the rep function can repeat a rule:

START {
rep(<RULE1>) <RULE2>
}

In the following script, two rules are called from the START rule, PERSON and LOCATION. Each rule uses the same pattern to find words until an end-of-line, but assigns values to different variables. The values of the variables are printed from an action block under START.

ASL Script (other_rules.asl):

START {
 PERSON LOCATION
}
do {
 print("Name: ".name);
 print("Address: ".address);
}
PERSON {
 name:rep(word) eol
}
LOCATION {
 address:rep(word) eol
}
Input (other_rules.txt):
Jay Ray
11 Main St
Jane Doe
34 Oak Dr
Output:
$ sm_adapter --file=other_rules.txt other_rules.asl
Name: Jay Ray
Address: 11 Main St
Name: Jane Doe
Address: 34 Oak Dr
$ 

In the next example, the DATE and PLACE rules are called from START. The DATE and PLACE rules are separated by an alternative operator. For each line of text where DATE matches, PLACE is not tested. If DATE does not match, PLACE is tested.

Notice how the variable assignment works in this example. When either DATE or PLACE matches, the entire matched string is returned and assigned to x. The end-of-line is added to the string, which affects the output.

ASL Script (operators_rules.asl):
START {
 x:{DATE|PLACE}
}
do {
 print("Day or place ".x);
}
DATE {
 integer.rep("/".integer,2)
 eol
}
PLACE {
 integer word word eol
}
DEFAULT {
 ..eol
}
do {
 print("Failed match");
}
Input (operators_rules.txt):
01/05/99
11 Main St
camel horse mule
10/31/01
34 Oak Dr
Output:
$ sm_adapter --file=operators_rules.txt operators_rules.asl
Day or place 01/05/99
Day or place 11 Main St
Failed match
Day or place 10/31/01
Day or place 34 Oak Dr
$