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

Rakudo does not recognize backslash escape sequences in character classes #1615

Closed
p6rt opened this issue Mar 20, 2010 · 7 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Mar 20, 2010

Migrated from rt.perl.org#73698 (status was 'resolved')

Searchable as RT73698$

@p6rt
Copy link
Author

p6rt commented Mar 20, 2010

From @moritz

23​:15 <@​moritz_> rakudo​: say 'foto' ~~ /<-[\t]>+/
23​:15 < p6eval> rakudo 3075a5​: OUTPUT«fo␤»
23​:15 * moritz_ bangs head against wall

should match the full string, of course...

@p6rt
Copy link
Author

p6rt commented Mar 21, 2010

From @moritz

The bug seems to be located in nqp-rx file src/Regex/P6Regex/Actions.pm
method cclass_elem​:

  for $<charspec> {
  if $_[1] {
  ...
  }
  else { $str := $str ~ $_[0]; }
  }
  $past := PAST​::Regex.new( $str, :pasttype('enumcharlist'),
:node($/) );

The $_[0] captures the 't' in a regex like <[\t]>, and concatenating it
like this seems oh so wrong, and explains why nqp-rx thinks <[\t]> is
the same as <[t]>.

I'm not sure what the best way of fixing this is; the logic for handling
backslash escapes is already present in method backslash​:sym<t> etc.;
maybe this can be factored out somehow to avoid code duplication.

@p6rt
Copy link
Author

p6rt commented Mar 21, 2010

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

@p6rt
Copy link
Author

p6rt commented Dec 22, 2010

From info@syntax-k.de

Hi!

I'm trying to do this​:

"a\nb" ~~ m/<-[\n\#\ \t]>+/

and it matches the whole string, while

"an\nb" ~~ m/<-[\n\#\ \t]>+/

matches "a" only. The positive cases behave consistently.

The data file I'm parsing can have about anything in a "word" that is not
whitespace, but it does allow #-style comments. The above regex doesn't
work, since \n and \t do not exclude newline/tab but "n" and "t". Isn't
this inconsistent with the "escaped letters are metacharacters" rule?

While searching for information, I found little about if/how this is
supposed to work, neither in S05, the spectests, nor the allmighty
internet. The only hint that someone else thought it should work this way
was the perl5 module Perl6​::Rules, which gives <[\w]-<digit>> as an
example. So this may actually be an oversight in S05, or something totally
obvious which I didn't find.

--
Mit freundlichen Grüßen,

  Jörg Walter

@p6rt
Copy link
Author

p6rt commented Jan 13, 2012

From @jnthn

On Sat Mar 20 15​:17​:42 2010, moritz wrote​:

23​:15 <@​moritz_> rakudo​: say 'foto' ~~ /<-[\t]>+/
23​:15 < p6eval> rakudo 3075a5​: OUTPUT«fo␤»
23​:15 * moritz_ bangs head against wall

should match the full string, of course...

This was fixed a bit ago​:

say 'foto' ~~ /<-[\t]>+/
=> <foto>

Tagging testneeded, though we may already have some.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 13, 2012

From @moritz

We have indeed test coverage, so closing ticket.

@p6rt
Copy link
Author

p6rt commented Jan 13, 2012

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

@p6rt p6rt closed this as completed Jan 13, 2012
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant