7.5 Backtracking Control

     

Backtracking is triggered whenever part of the pattern fails to match. You can also explicitly trigger backtracking by calling the fail function within a closure. Table 7-8 shows some metacharacters and built-in rules relevant to backtracking.

Table 7-8. Backtracking controls

Operator

Meaning

:

Don't retry the previous atom; fail to the next earlier atom.

: :

Don't backtrack over this point; fail out of the closest enclosing group ( ( . . . ) , [ . . . ] , or the rule delimiters).

:: :

Don't backtrack over this point; fail out of the current rule or subrule.

<commit>

Don't backtrack over this point; fail out of the entire match (even from within a subrule).

<cut>

Like <commit> , but also cuts the string matched. The current matching position at this point becomes the new beginning of the string.




Perl 6 and Parrot Essentials
Perl 6 and Parrot Essentials, Second Edition
ISBN: 059600737X
EAN: 2147483647
Year: 2003
Pages: 116

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net