For complicated inputs, the pattern matching can be divided among different rules by using the input variable. The input variable is assigned to a value which ASL uses for the pattern matching that follows the input. The input variable must come at the beginning of a rule, before any pattern matching but not at the beginning of a script. If the value assigned to the input variable does not end with an eol, an eol is appended to the value. The syntax is as follows:

input=<value>;

For example, the following script looks for lines of input that start with the string “Error:”. When it finds those strings, the rest of the words are assigned to the variable desc and the rule PROCESSDESC is called.

PROCESSDESC takes the variable desc as its input and performs pattern matching based on the input. The error level and error message are printed.

The START rule processes the next line data and, if it is an error, PROCESSDESC runs again. At the end of the input file, the rule EOF runs. This rule prints a statement that the errors are processed.

ASL Script (input_ex.asl):
START {
 "Error:" desc:rep(word) eol
 PROCESSDESC
}
PROCESSDESC {
 input=desc;
 errornumber:integer
 errorlevel:word
 errormsg:rep(word)
 eol
}
do {
 print(errorlevel." ".errormsg);
}
DEFAULT {
 ..eol
}
do {
 print("No Error");
}
EOF
do {
 print();
 print("Errors Processed");
}
Input (input_ex.txt):
Error: 2568 Severe Can't process
Status: 2358 Starting backup
Error: 1202 Warning Bad data
Error: 923 Critical Wrong Number
Output:
$ sm_adapter --file=input_ex.txt input_ex.asl
Severe Can't process
No Error
Warning Bad data
Critical Wrong Number
Errors Processed
$