Back Up and Retry
Multitoken matching operators, such as $+
, always try to match
the least that they can (Backup and Retry on page 660). Such a
simple-minded approach could lead to problems in
matching (or not matching) classes in the LHS.
However, the ability of
sendmail to back up and retry
alleviates this problem. For example, consider the
following five tokens in the workspace:
"A" "." "B" "." "C"
and consider the following LHS rule:
R $+ . $=X $*
Because the $+
tries to match the minimum, it first matches only
the A
in the
workspace. The $=X
then tries to match the B
. and then B.C
to the class
$=X
. If this
match fails, sendmail backs up
to the $+
and
tries again.
The next time through, the $+
matches A
. in the workspace, but that fails to
match the dot in the rule, so it backs up again and
matches A.B
. The
$=X
tries to
match the C
in
the workspace. If C
is not in the class $=X
, the entire LHS
fails.
The ability of the sendmail program to back up and retry LHS matches eliminates much of the ambiguity from rule design. The multitoken matching operators try to match the minimum but match more if necessary for the whole LHS to match.
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.