Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Possible ws modifier and capture bug

1 view
Skip to first unread message

Dino Morelli

unread,
May 23, 2005, 4:14:41 PM5/23/05
to Perl 6 Internals list
I think I may have found something wrong with PGE capturing with the :w
modifier. In this code:


.sub main @MAIN
.local pmc p6rule, rulesub, match
.local string input

input = "dog spot"


load_bytecode "runtime/parrot/library/PGE.pbc"
p6rule = find_global "PGE", "p6rule"


rulesub = p6rule(':w(\w+) (\S+)')
match = rulesub(input)
$S0 = match.dump()
print $S0
print "\n\n"


rulesub = p6rule('(\w+)\s+(\S+)')
match = rulesub(input)
$S0 = match.dump()
print $S0
print "\n"
.end


The first match is getting 'dog' in both 0 and 1 and never capturing
'spot' I think it should be like the second one (which doesn't use :w
but should be the same expression). Output:


: <dog @ 0> 0
[0]: <dog @ 0> 0
[1]: <dog @ 0> 0
dog spot

: <dog spot @ 0> 0
[0]: <dog @ 0> 0
[1]: <spot @ 4> 0
dog spot


-Dino

--
.~. Dino Morelli
/V\ email: dmor...@reactorweb.net
/( )\ weblog: http://categorically.net/d/blog/
^^-^^ preferred distro: Debian GNU/Linux http://www.debian.org

Patrick R. Michaud

unread,
May 23, 2005, 5:29:52 PM5/23/05
to Dino Morelli, Perl 6 Internals list
On Mon, May 23, 2005 at 04:14:41PM -0400, Dino Morelli wrote:
> I think I may have found something wrong with PGE capturing with the :w
> modifier. In this code:
> [...]

You're correct, the <?ws> rule wasn't working properly. I must've
been sleep deprived when I originally wrote it, as it wasn't handling
the C<pos> value correctly at all. It should be fixed now (r8147 --
see output below). Thanks!

Pm

--------

input "rule <pattern>", "glob <pattern>", "save <name>",
target string, "pir", "exp", "trace", or "next"
rule :w(\w+) (\S+)

input "rule <pattern>", "glob <pattern>", "save <name>",
target string, "pir", "exp", "trace", or "next"
dog spot
match succeeded
$/: <dog spot @ 0> 0
$/[0]: <dog @ 0> 0
$/[1]: <spot @ 4> 0

0 new messages