[svn:parrot] r38380 - in trunk: compilers/pge/PGE t/compilers/pge/perl6regex
pmichaud at svn.parrot.org
pmichaud at svn.parrot.org
Tue Apr 28 01:50:38 UTC 2009
Author: pmichaud
Date: Tue Apr 28 01:50:36 2009
New Revision: 38380
URL: https://trac.parrot.org/parrot/changeset/38380
Log:
[pge]: Some whitespace fixes in \c[...], \x[...], and #= keys (RT #53464)
* trim whitespace around #= keys
* allow more whitespace inside of \c[...], \x[...], and \o[...]
Modified:
trunk/compilers/pge/PGE/Perl6Regex.pir
trunk/t/compilers/pge/perl6regex/rx_metachars
Modified: trunk/compilers/pge/PGE/Perl6Regex.pir
==============================================================================
--- trunk/compilers/pge/PGE/Perl6Regex.pir Mon Apr 27 18:57:29 2009 (r38379)
+++ trunk/compilers/pge/PGE/Perl6Regex.pir Tue Apr 28 01:50:36 2009 (r38380)
@@ -159,6 +159,24 @@
=cut
+.sub 'trim'
+ .param string s
+ .local int rpos, lpos
+ rpos = length s
+ lpos = find_not_cclass .CCLASS_WHITESPACE, s, 0, rpos
+ rtrim_loop:
+ unless rpos > lpos goto rtrim_done
+ dec rpos
+ $I0 = is_cclass .CCLASS_WHITESPACE, s, rpos
+ if $I0 goto rtrim_loop
+ rtrim_done:
+ inc rpos
+ $I0 = rpos - lpos
+ $S0 = substr s, lpos, $I0
+ .return ($S0)
+.end
+
+
.sub 'p6escapes'
.param pmc mob
.param pmc adverbs :slurpy :named
@@ -224,6 +242,7 @@
have_namepos:
$I0 = namepos - pos
$S0 = substr target, pos, $I0
+ $S0 = 'trim'($S0)
$P0 = new 'CodeString'
decnum = $P0.'charname_to_ord'($S0)
if decnum < 0 goto err_unicode_name
@@ -242,8 +261,9 @@
scan_xco_char_end:
$S1 = chr decnum
concat literal, $S1
- $S0 = substr target, pos, 1
unless isbracketed goto scan_xco_end
+ pos = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
+ $S0 = substr target, pos, 1
if $S0 == ']' goto scan_xco_end
if $S0 == '' goto err_missing_bracket
if $S0 != ',' goto err_digit
@@ -1339,6 +1359,7 @@
keypos += 3
$I0 -= keypos
actionkey = substr target, keypos, $I0
+ actionkey = 'trim'(actionkey)
mob['actionkey'] = actionkey
end:
mob.'to'(pos)
Modified: trunk/t/compilers/pge/perl6regex/rx_metachars
==============================================================================
--- trunk/t/compilers/pge/perl6regex/rx_metachars Mon Apr 27 18:57:29 2009 (r38379)
+++ trunk/t/compilers/pge/perl6regex/rx_metachars Tue Apr 28 01:50:36 2009 (r38380)
@@ -190,6 +190,8 @@
c \x[0021] d abc!def y hex (\x[])
c \x[0021]+ d abc!!def y hex (\x[])
c \x[21,21] d abc!!def y hex (\x[])
+c \x[21, 21] d abc!!def y hex (\x[])
+c \x[ 21 , 21 ] d abc!!def y hex (\x[])
a \x[0021]+ f abcdef n hex (\x[])
b \x[0021] c abc!def n hex (\x[])
\X0021 a y not hex (\X)
@@ -211,6 +213,8 @@
c \c[33] d abc!def y hex (\x[])
c \c[33]+ d abc!!def y hex (\x[])
c \c[33,33] d abc!!def y hex (\x[])
+c \c[ 33, 33] d abc!!def y hex (\x[])
+c \c[ 33 , 33 ] d abc!!def y hex (\x[])
a \c[33]+ f abcdef n hex (\x[])
b \c[33] c abc!def n hex (\x[])
\C33 a y not hex (\X)
More information about the parrot-commits
mailing list