Author: pmichaud
Date: Thu Apr 5 05:45:35 2007
New Revision: 17994
Added:
trunk/t/compilers/pge/perl6regex/rx_captures
Modified:
trunk/MANIFEST
trunk/t/compilers/pge/perl6regex/01-regex.t
Log:
[pge]:
* Merge rx_captures from p6regex and pugs test suites.
* Add "# trace" option to 01-regex.t
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Thu Apr 5 05:45:35 2007
@@ -2747,6 +2747,7 @@
t/compilers/pge/p6regex/text_brk.t []
t/compilers/pge/perl6regex/01-regex.t []
t/compilers/pge/perl6regex/rx_backtrack []
+t/compilers/pge/perl6regex/rx_captures []
t/compilers/pge/perl6regex/rx_charclass []
t/compilers/pge/perl6regex/rx_metachars []
t/compilers/pge/pge-hs.t []
Modified: trunk/t/compilers/pge/perl6regex/01-regex.t
==============================================================================
--- trunk/t/compilers/pge/perl6regex/01-regex.t (original)
+++ trunk/t/compilers/pge/perl6regex/01-regex.t Thu Apr 5 05:45:35 2007
@@ -77,7 +77,7 @@
push test_files, 'rx_charclass'
# push test_files, 'rx_subrules'
# push test_files, 'rx_lookarounds'
- # push test_files, 'rx_captures'
+ push test_files, 'rx_captures'
# push test_files, 'rx_modifiers'
.local pmc interp # a handle to our interpreter object.
@@ -141,6 +141,7 @@
next_test:
skiptest = 0
todotest = 0
+ trace 0
# loop over the file, one at a time.
loop:
@@ -167,9 +168,21 @@
reason = substr test_line, $I0, $I1
# determine skip/todo
- $S0 = substr test_line, 0, 7
- skiptest = iseq $S0, '# skip '
- todotest = iseq $S0, '# todo '
+ $P0 = split ' ', test_line
+ $S0 = $P0[1]
+ if $S0 == 'skip' goto comment_skip
+ if $S0 == 'todo' goto comment_todo
+ if $S0 == 'trace' goto comment_trace
+ goto loop
+ comment_skip:
+ skiptest = 1
+ goto loop
+ comment_todo:
+ todotest = 1
+ goto loop
+ comment_trace:
+ $I0 = reason
+ trace $I0
goto loop
parse_test:
@@ -422,9 +435,6 @@
.sub backslash_escape
.param string target
- .local int x_pos # position in string of last \x escape..
- x_pos = 0
-
target1:
$I0 = index target, '\n'
if $I0 == -1 goto target2
@@ -451,9 +461,9 @@
substr target, $I0, 2, "\f"
goto target5
target6:
- # handle \xHH, hex escape.
+ # handle \xHH, hex escape.
- $I0 = index target, '\x', x_pos
+ $I0 = index target, '\x'
if $I0 == -1 goto target7
$I1 = $I0 + 2
Added: trunk/t/compilers/pge/perl6regex/rx_captures
==============================================================================
--- (empty file)
+++ trunk/t/compilers/pge/perl6regex/rx_captures Thu Apr 5 05:45:35 2007
@@ -0,0 +1,60 @@
+## captures
+(a.)..(..) zzzabcdefzzz y basic match
+(a.)..(..) zzzabcdefzzz /mob: <abcdef @ 3>/ basic $0
+(a.)..(..) zzzabcdefzzz /mob 0: <ab @ 3>/ basic $1
+(a.)..(..) zzzabcdefzzz /mob 1: <ef @ 7>/ basic $2
+(a(b(c))(d)) abcd y nested match
+(a(b(c))(d)) abcd /mob: <abcd @ 0>/ nested match
+(a(b(c))(d)) abcd /mob 0: <abcd @ 0>/ nested match
+(a(b(c))(d)) abcd /mob 0 0: <bc @ 1>/ nested match
+(a(b(c))(d)) abcd /mob 0 0 0: <c @ 2>/ nested match
+(a(b(c))(d)) abcd /mob 0 1: <d @ 3>/ nested match
+((\w+)+) abcd /mob: <abcd @ 0>/ nested match
+((\w+)+) abcd /mob 0: <abcd @ 0>/ nested match
+((\w+)+) abcd /mob 0 0 0: <abcd @ 0>/ nested match
+((\w+)+)
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
/mob: <ABCD/ nested match
+((\w+)+)
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
/mob 0: <ABCD/ nested match
+((\w+)+)
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
/mob 0 0 0: <ABCD/ nested match
+(a) [ (bc) (d) | .* (ef) ] .* (g) abcdefg /mob 0: <a @ 0>/ alt
subpattern before group
+(a) [ (bc) (d) | .* (ef) ] .* (g) abcdefg /mob 1: <bc @ 1>/ alt
subpattern in group
+(a) [ (bc) (d) | .* (ef) ] .* (g) abcdefg /mob 2: <d @ 3>/ alt
subpattern in group
+(a) [ (bc) (d) | .* (ef) ] .* (g) abcdefg /mob 3: <g @ 6>/ alt
subpattern after group
+(a) [ (bc) (x) | .* (ef) ] .* (g) abcdefg /mob 1: <ef @ 4>/ 2nd alt
subpattern in group
+(a) [ (bc) (x) | .* (ef) ] .* (g) abcdefg /mob 3: <g @ 6>/ 2nd alt
subpattern after group
+( (.) )* abc /mob 0 1 0: <b @ 1>/ nested
repeated captures
+[ (.) ]* abc /mob 0 1: <b @ 1>/ nested
repeated captures
+( [.] )* abc /mob 0 1: <b @ 1>/ nested
repeated captures
+(.) (.) $7:=(.) (.) $4:=(.) abcdefg /mob 0: <a @ 0>/
numbered aliases $1
+(.) (.) $7:=(.) (.) $4:=(.) abcdefg /mob 1: <b @ 1>/
numbered aliases $2
+(.) (.) $7:=(.) (.) $4:=(.) abcdefg /mob 7: <c @ 2>/
numbered aliases $7
+(.) (.) $7:=(.) (.) $4:=(.) abcdefg /mob 8: <d @ 3>/
numbered aliases $8
+(.) (.) $7:=(.) (.) $4:=(.) abcdefg /mob 4: <e @ 4>/
numbered aliases $4
+$1:=[ (.) (.) (.) ] (.) abcdefg /mob 1: <abc @ 0>/
perl5 numbered captures $1
+$1:=[ (.) (.) (.) ] (.) abcdefg /mob 2: <a @ 0>/
perl5 numbered captures $1
+$1:=[ (.) (.) (.) ] (.) abcdefg /mob 3: <b @ 1>/
perl5 numbered captures $1
+$1:=[ (.) (.) (.) ] (.) abcdefg /mob 4: <c @ 2>/
perl5 numbered captures $1
+$1:=[ (.) (.) (.) ] (.) abcdefg /mob 5: <d @ 3>/
perl5 numbered captures $1
+# todo :pugs<feature>
+:s $<key>:=[\w+] \= $<val>:=[\S+] abc = 123 /mob<key>: <abc @ 1>/
named capture
+# todo :pugs<feature>
+:s $<key>:=[\w+] \= $<val>:=[\S+] abc = 123 /mob<val>: <123 @ 7>/
named capture
+# todo :pugs<feature>
+:s (\w+) $<foo>:=(\w+) (\w+) abc def ghi /mob<foo>: <def @ 4>/
mixing named and unnamed capture
+# todo :pugs<feature>
+:s (\w+) $<foo>:=(\w+) (\w+) abc def ghi /mob 1: <ghi @ 8>/
mixing named and unnamed capture
+# todo :pugs<feature>
+<alpha> [ \- <alpha> ]? abc def ghi /mob<alpha> 0:
<a @ 0>/ multiple subrule captures in same scope
+# todo :pugs<feature>
+[(.)$0]+ bookkeeper y
backreference
+# todo :pugs<feature>
+(\w+) <?ws> $0 hello hello y
backreference at end of string
+# todo :pugs<feature>
+[(.)$0]+ bookkeeper /mob 0 0: <o @ 1>/
backref $1
+# todo :pugs<feature>
+[(.)$0]+ bookkeeper /mob 0 1: <k @ 3>/
backref $1
+# todo :pugs<feature>
+[(.)$0]+ bookkeeper /mob 0 2: <e @ 5>/
backref $1
+# todo :pugs<feature>
+(.)*x 123x /mob: <123x @ 0>/
repeated dot capture
+
+## vim: noexpandtab tabstop=4 shiftwidth=4