Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backtracking/capturing problem #2556

Closed
p6rt opened this issue Nov 11, 2011 · 5 comments
Closed

backtracking/capturing problem #2556

p6rt opened this issue Nov 11, 2011 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Nov 11, 2011

Migrated from rt.perl.org#103412 (status was 'rejected')

Searchable as RT103412$

@p6rt
Copy link
Author

p6rt commented Nov 11, 2011

From mark@kli.org

 

 
 
 
  $ perl6 --version
This is perl6 version 2011.10-98-g1985138 built on parrot 3.9.0 revision RELEASE_3_9_0-51-g65e6ab7
$ perl6

"e u a u e u a" ~~ /​:sigspace ("a") ([<[aeiou]> ]+)$/
=> < a u e u a>
0 => <a>
1 => <u e u a>

"e u a u e u a" ~~ /​:sigspace .("a") ([<[aeiou]> ]+)$/
#<failed match>
# Only a single . was added before the ("a"), which is plainly not at the beginning of the line.
"e u a u e u a" ~~ /​:sigspace .?("a") ([<[aeiou]> ]+)$/
=> < a u e u a>
0 => <a>
1 => <u e u a>

# OK, making the . optional works, but what if I try to capture it?
"e u a u e u a" ~~ /​:sigspace (.?)("a") ([<[aeiou]> ]+)$/
#<failed match>
# Surely choosing to capture a part of the match shouldn't affect whether it matches at all!

This all works differently if we use a space between the . and the ("a"). It looks like
at least some my own difficulty in the particular case relates to the space after
the :sigspace adverb counting as whitespace, but does that explain everything?

~mark

 

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @moritz

A shorter way to reproduce the same thing​:

"u a" ~~ /​:sigspace .'a'/
#<failed match>

Or even

"u " ~~ /<.ws>.$/
#<failed match>

So, seems to be a problem with <.ws>, and not captures or backtracking
(at least not anymore :-)

@p6rt
Copy link
Author

p6rt commented May 29, 2012

@moritz - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

From @moritz

On second thought, it's not even a bug​: <.ws> doesn't backtrack. It
matches the space on the first pass through, and doesn't give it up
anymore, so the . has nothing to match.

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

@moritz - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant