# New Ticket Created by equinox
# Please include the string: [perl #68984]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=68984 >
Hi,
I converted this into pir...using rakudo-2009-07.
my $p=0;
my $str="aaaa a a b aaaa";
while (substr($str,$p)~~/(a)|(b)/) #~~ is instread of =~
{
print "match found at $p>>{$0 // "not found"}<< or >>{$2 // "not
found"}<<\n"; #$0 denotes the first capturing group.(a)
$p+=$/.to;
}
When I tried it to converter into pbc.
D:\standalone\parrot-1.4.0>parrot rakudo-2009-07\p.pir p.pbc
error:imcc:syntax error, unexpected PREG, expecting '(' ('$P80')
in file 'rakudo-2009-07\p.pir' line 303
Mp
.HLL "perl6"
.namespace []
.sub "_block11" :main :anon :subid("12_1252015504")
.param pmc param_87 :slurpy
.annotate "line", 0
.const 'Sub' $P89 = "18_1252015504"
capture_lex $P89
.annotate 'file', 'D:\m\p6\regs.p6'
find_name $P13, "!UNIT_START"
.annotate "line", 1
.const 'Sub' $P15 = "13_1252015504"
.lex "@_", param_87
.tailcall $P13($P15, param_87)
.annotate "line", 0
.return ()
.end
.HLL "perl6"
.namespace []
.sub "" :load :init :subid("post19") :outer("12_1252015504")
.annotate "line", 0
.const 'Sub' $P12 = "12_1252015504"
.local pmc block
set block, $P12
$P0 = compreg "perl6"
unless null $P0 goto have_perl6
load_bytecode "perl6.pbc"
have_perl6:
.end
.HLL "perl6"
.namespace []
.sub "_block14" :anon :subid("13_1252015504")
.annotate "line", 1
.const 'Sub' $P33 = "15_1252015504"
capture_lex $P33
.const 'Sub' $P30 = "14_1252015504"
capture_lex $P30
get_namespace $P16
.lex "$?PACKAGE", $P16
.include "interpinfo.pasm"
$P17 = root_new ["parrot";"Perl6Scalar"]
.lex "$_", $P17
$P18 = root_new ["parrot";"Perl6Scalar"]
.lex "$/", $P18
$P19 = root_new ["parrot";"Perl6Scalar"]
.lex "$!", $P19
new $P20, "Perl6Scalar"
.local pmc initvar_10
set initvar_10, $P20
$P21 = initvar_10
.lex "$p", $P21
new $P22, "Int"
assign $P22, 0
"infix:="($P21, $P22)
.annotate "line", 2
new $P23, "Perl6Scalar"
.local pmc initvar_11
set initvar_11, $P23
$P24 = initvar_11
.lex "$str", $P24
new $P25, "Str"
assign $P25, "aaaa a a b aaaa"
"infix:="($P24, $P25)
.annotate "line", 4
new $P85, 'ExceptionHandler'
set_addr $P85, loop84_handler
$P85."handle_types"(65, 67, 66)
push_eh $P85
loop84_test:
find_lex $P26, "$str"
find_lex $P27, "$p"
$P28 = "substr"($P26, $P27)
.const 'Sub' $P30 = "14_1252015504"
capture_lex $P30
$P31 = "infix:~~"($P28, $P30)
unless $P31, loop84_done
loop84_redo:
.annotate "line", 5
.const 'Sub' $P33 = "15_1252015504"
capture_lex $P33
$P33()
loop84_next:
goto loop84_test
loop84_handler:
.local pmc exception
.get_results (exception)
getattribute $P86, exception, 'type'
eq $P86, 65, loop84_next
eq $P86, 67, loop84_redo
loop84_done:
pop_eh
.annotate "line", 1
.return ($P31)
.end
.namespace ["PGE";"Grammar"]
.sub "_block29" :method :anon :subid("14_1252015504")
:outer("13_1252015504")
.param pmc adverbs :slurpy :named
.local pmc mob
.const 'Sub' corou = "_block29_corou"
$P0 = corou
$P0 = clone $P0
mob = $P0(self, adverbs)
.return (mob)
.end
.sub '' :subid("_block29_corou")
.param pmc mob :unique_reg
.param pmc adverbs :unique_reg
.local string target :unique_reg
.local pmc mfrom, mpos :unique_reg
.local int cpos, iscont :unique_reg
$P0 = get_hll_global ['PGE'], '$!MATCH'
(mob, cpos, target, mfrom, mpos, iscont) = $P0.'new'(mob, adverbs
:flat :named)
$P0 = interpinfo 15
setattribute mob, '&!corou', $P0
.local int lastpos
lastpos = length target
if cpos > lastpos goto fail_rule
.local pmc cstack :unique_reg
cstack = root_new ['parrot';'ResizableIntegerArray']
.local pmc ustack :unique_reg
ustack = root_new ['parrot';'ResizablePMCArray']
.local pmc gpad :unique_reg
gpad = root_new ['parrot';'ResizablePMCArray']
.local pmc captscope, captob :unique_reg
captscope = mob
.local int pos, rep, cutmark :unique_reg
try_match:
if cpos > lastpos goto fail_rule
mfrom = cpos
pos = cpos
cutmark = 0
local_branch cstack, R
if cutmark <= -2 goto fail_cut
inc cpos
if iscont goto try_match
fail_rule:
cutmark = -2
fail_cut:
mob.'_failcut'(cutmark)
.yield (mob)
goto fail_cut
succeed:
mpos = pos
.yield (mob)
fail:
local_return cstack
R: # alt R40, R41
push ustack, pos
local_branch cstack, R40
pos = pop ustack
if cutmark != 0 goto fail
goto R41
R40: # capture
captob = captscope.'new'(captscope, 'pos'=>pos)
push gpad, captscope
push gpad, captob
captscope = captob
local_branch cstack, R42
captob = pop gpad
captscope = pop gpad
### if cutmark != 0 goto fail
### cutmark = 0
goto fail
R40_close:
push ustack, captscope
captob = pop gpad
captscope = pop gpad
$P1 = getattribute captob, '$.pos'
$P1 = pos
captscope[0] = captob
push ustack, captob
local_branch cstack, succeed
captob = pop ustack
delete captscope[0]
push gpad, captscope
push gpad, captob
captscope = pop ustack
goto fail
R42: # literal
$I0 = pos + 1
if $I0 > lastpos goto fail
$S0 = substr target, pos, 1
if $S0 != "a" goto fail
pos += 1
goto R40_close
R41: # capture
captob = captscope.'new'(captscope, 'pos'=>pos)
push gpad, captscope
push gpad, captob
captscope = captob
local_branch cstack, R43
captob = pop gpad
captscope = pop gpad
### if cutmark != 0 goto fail
### cutmark = 0
goto fail
R41_close:
push ustack, captscope
captob = pop gpad
captscope = pop gpad
$P1 = getattribute captob, '$.pos'
$P1 = pos
captscope[0] = captob
push ustack, captob
local_branch cstack, succeed
captob = pop ustack
delete captscope[0]
push gpad, captscope
push gpad, captob
captscope = pop ustack
goto fail
R43: # literal
$I0 = pos + 1
if $I0 > lastpos goto fail
$S0 = substr target, pos, 1
if $S0 != "b" goto fail
pos += 1
goto R41_close
.end
.HLL "perl6"
.namespace []
.sub "" :load :init :subid("post20") :outer("14_1252015504")
.annotate "line", 4
.const 'Sub' $P30 = "14_1252015504"
.local pmc block
set block, $P30
"!fixup_routine_type"(block, "Regex")
$P0 = getattribute block, ['Sub'], 'proxy'
setprop $P0, '$!real_self', block
.end
.HLL "perl6"
.namespace []
.sub "_block32" :anon :subid("15_1252015504") :outer("13_1252015504")
.annotate "line", 5
.const 'Sub' $P62 = "17_1252015504"
capture_lex $P62
.const 'Sub' $P44 = "16_1252015504"
capture_lex $P44
.local pmc outerlex
getinterp $P0
set outerlex, $P0["outer";"lexpad";1]
set $P34, outerlex["$_"]
.lex "$_", $P34
set $P35, outerlex["$/"]
.lex "$/", $P35
set $P36, outerlex["$!"]
.lex "$!", $P36
.annotate "line", 6
new $P37, "Str"
assign $P37, "match found at "
find_lex $P38, "$p"
$S39 = "prefix:~"($P38)
concat $P40, $P37, $S39
new $P41, "Str"
assign $P41, ">>"
concat $P42, $P40, $P41
.const 'Sub' $P44 = "16_1252015504"
capture_lex $P44
$P56 = $P44()
$S57 = "prefix:~"($P56)
concat $P58, $P42, $S57
new $P59, "Str"
assign $P59, "<< or >>"
concat $P60, $P58, $P59
.const 'Sub' $P62 = "17_1252015504"
capture_lex $P62
$P74 = $P62()
$S75 = "prefix:~"($P74)
concat $P76, $P60, $S75
new $P77, "Str"
assign $P77, "<<\n"
concat $P78, $P76, $P77
"print"($P78)
.annotate "line", 7
find_lex $P79, "$p"
find_lex $P80, "$/"
$P81 = descalarref $P80
$P82 = $P81."to"()
$P83 = "infix:+="($P79, $P82)
.annotate "line", 5
.return ($P83)
.end
.HLL "perl6"
.namespace []
.sub "" :load :init :subid("post21") :outer("15_1252015504")
.annotate "line", 5
.const 'Sub' $P33 = "15_1252015504"
.local pmc block
set block, $P33
"!fixup_routine_type"(block, "Block")
$P0 = getattribute block, ['Sub'], 'proxy'
setprop $P0, '$!real_self', block
.end
.HLL "perl6"
.namespace []
.sub "_block43" :anon :subid("16_1252015504") :outer("15_1252015504")
.param pmc param_45 :optional
.param int has_param_45 :opt_flag
.annotate "line", 6
.local pmc outerlex
getinterp $P0
set outerlex, $P0["outer";"lexpad";1]
if has_param_45, optparam_23
set $P46, outerlex["$_"]
set param_45, $P46
optparam_23:
.lex "$_", param_45
set $P47, outerlex["$/"]
.lex "$/", $P47
set $P48, outerlex["$!"]
.lex "$!", $P48
find_lex $P50, "$/"
set $P51, $P50[0]
unless_null $P51, vivify_24
new $P51, "Failure"
vivify_24:
set $P49, $P51
defined $I53, $P49
if $I53, default_52
new $P54, "Str"
assign $P54, "not found"
set $P49, $P54
default_52:
.return ($P49)
.end
.HLL "perl6"
.namespace []
.sub "" :load :init :subid("post22") :outer("16_1252015504")
.annotate "line", 6
.const 'Sub' $P44 = "16_1252015504"
.local pmc block
set block, $P44
"!fixup_routine_type"(block, "Block")
$P0 = getattribute block, ['Sub'], 'proxy'
setprop $P0, '$!real_self', block
get_hll_global $P55, "Object"
.local pmc signature
signature = new ["Signature"]
setprop block, "$!signature", signature
signature."!set_default_param_type"($P55)
signature."!add_param"("$_", 1 :named("optional"))
.end
.HLL "perl6"
.namespace []
.sub "_block61" :anon :subid("17_1252015504") :outer("15_1252015504")
.param pmc param_63 :optional
.param int has_param_63 :opt_flag
.annotate "line", 6
.local pmc outerlex
getinterp $P0
set outerlex, $P0["outer";"lexpad";1]
if has_param_63, optparam_26
set $P64, outerlex["$_"]
set param_63, $P64
optparam_26:
.lex "$_", param_63
set $P65, outerlex["$/"]
.lex "$/", $P65
set $P66, outerlex["$!"]
.lex "$!", $P66
find_lex $P68, "$/"
set $P69, $P68[2]
unless_null $P69, vivify_27
new $P69, "Failure"
vivify_27:
set $P67, $P69
defined $I71, $P67
if $I71, default_70
new $P72, "Str"
assign $P72, "not found"
set $P67, $P72
default_70:
.return ($P67)
.end
.HLL "perl6"
.namespace []
.sub "" :load :init :subid("post25") :outer("17_1252015504")
.annotate "line", 6
.const 'Sub' $P62 = "17_1252015504"
.local pmc block
set block, $P62
"!fixup_routine_type"(block, "Block")
$P0 = getattribute block, ['Sub'], 'proxy'
setprop $P0, '$!real_self', block
get_hll_global $P73, "Object"
.local pmc signature
signature = new ["Signature"]
setprop block, "$!signature", signature
signature."!set_default_param_type"($P73)
signature."!add_param"("$_", 1 :named("optional"))
.end
.HLL "perl6"
.namespace []
.sub "_block88" :load :anon :subid("18_1252015504") :outer("12_1252015504")
.annotate "line", 0
.include "interpinfo.pasm"
$P0 = interpinfo .INTERPINFO_CURRENT_SUB
$P0 = $P0."get_outer"()
$P0()
.return ()
.end