Boolean expressions can be added to a pattern list. If a Boolean expression fails, the pattern match also fails.
Note:
Boolean expressions are more commonly used in the filter section of a rule than in the pattern matching block. Unlike Boolean expressions in a pattern, a failing Boolean expression in a filter does not cause the rule to fail.
The following script matches a name and an integer. The Boolean expression is:
number>2
If the integer is greater than two, the match succeeds.
For every line in the input, the word, the integer and the eol are successfully matched. When the Boolean expression causes the pattern to fail, the DEFAULT rule is executed and Failed Match is printed.
ASL Script (bool_match.asl): START { animal:word number:integer eol number>2 } do { print("Animal ".animal); print("Number ".number); } DEFAULT { ..eol } do { print("Failed match"); } Input (bool_match.txt): elephants 4 moose 1 tigers 2 giraffes 3 Output: $ sm_adapter --file=bool_match.txt bool_match.asl Animal elephants Number 4 Failed match Failed match Animal giraffes Number 3 $