> I think I can distinguish :: from ::: - :: fails the current branch point,
> whereas ::: fails the entire rule. 

Correct.

> I think I can distinguish between ::: and <commit>; the implementation
> is a bit tricky, because ::: fails the current match - easy enough -
> whereas <commit> has to specify to all upper-level matches that they
> failed too. Is it reasonable for failing a <commit> to be an exception?

It's not an exception, but you could certainly *implement* it that way.


> I don't think I can distinguish between : and ::. Essentially, how many
> nodes does each commit to? I would expect the following
> 
>         [ a+ : b | c+ : d | e+ : f ]
> 
> to do precisely the same as 
> 
>         [ a+ :: b | c+ :: d | e+ :: f ]

It doesn't. The first says:

        [         # Non-capturingly...
            a+    #    Match 1+ a's
            :     #    And never backtrack to match fewer a's
            b     #    Then match a b
        |         # Or if that failed...
            c+    #    Match 1+ c's
            :     #    And never backtrack to match fewer c's
            d     #    Then match a d
        |         # Or if that failed...
            e+    #    Match 1+ e's
            :     #    And never backtrack to match fewer e's
            f     #    Then match an
        ]

whereas the second says:

        [         # Non-capturingly...
            a+    #    Match 1+ a's
            ::    #    And if you ever have to backtrack,
                   #      then immediately fail the entire surrounding group
            b     #    Then match a b
        |         # Or if that failed...
            c+    #    Match 1+ c's
            ::    #    And if you ever have to backtrack,
                   #      then immediately fail the entire surrounding group
            d     #    Then match a d
        |         # Or if that failed...
            e+    #    Match 1+ e's
             ::    #    And if you ever have to backtrack,
                   #      then immediately fail the entire surrounding group
            f     #    Then match an f
        ]

So a single colon has the same effect as the Perl 5 (?>...) metasyntax.


> I don't see why Larry describes one as "if-then", but not the other.
> Basically, I don't think I'm sure what : "gives up".

It gives up tracktracking the immediately preceding atom.
The behaviour is explained quite well in E5 I think.

Damian

Reply via email to