from a read of the spec, the expected behavior of this code is unclear to me.

in the rule, i'm matching the builtin whitespace rule, creating an
alias with the same name as the named rule, and matching the builtin
rule again. this brings up a few questions:

does the alias replace the named rule or coexist with it?
when does the binding of the alias to the pattern occur?

.sub 'main' :main
        load_bytecode 'PGE.pbc'
        load_bytecode 'PGE/dumper.pir'
        .local pmc p6rule, rulesub, match
        .local string target
        .local int try
        
        p6rule = find_global 'PGE', 'p6rule'
        rulesub = p6rule('<ws> $<ws>:=(foo) <ws>')

        try = 1

        target = ' foo '
        bsr Do_match

        target = ' foofoo'
        bsr Do_match

        target = 'foofoofoo'
        bsr Do_match

        goto End

Do_match:
        match = rulesub(target)
        print 'match #'
        print try
        print "\n"
        match.'dump'()
        print "\n"
        inc try
        ret
End:
.end

here's what pge currently does, but i'm not certain this behavior is
correct, because it's implementation is not yet complete.

match #1
: < foo  @ 0> 0
<ws>[0]: <  @ 0> 0
<ws>[1]: <foo @ 1> 0
<ws>[2]: <  @ 4> 0

match #2
:0

match #3
:0

is this what you expected?
~jerry

Reply via email to