[perl #35439] [BUG] PGE: 'index' op not found when creating rule

0 views
Skip to first unread message

Jerry Gay

unread,
May 13, 2005, 7:57:19 PM5/13/05
to bugs-bi...@rt.perl.org
# New Ticket Created by jerry gay
# Please include the string: [perl #35439]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=35439 >


with parrot revision 8086, i'm running the following:

.sub main @MAIN
load_bytecode 'PGE.pbc'
.local pmc p6rule, rulesub, match
p6rule= find_global 'PGE', 'p6rule'
rulesub= p6rule( '( \\ \. )+ \\' )
.end


which, under parrot -t, gives thousands of lines of output.
eventually, i get the following...

# Back in sub 'PGE :: p6rule'
20035 compreg P15, "PIR" - P15=Sub=PMC(0x7d3260 Adr:0x8b6d88),
20038 set S30, P17 - , P17=String=PMC(0x7d2e88 Str:".sub _pge_rule\n .")
20041 compile P30, P15, S30 -
P30=Object(PGE::Exp::End)=PMC(0x7d3c20), P15=Compiler=PMC(0x7d5a98),
S30=".sub _pge_rule\n ."
error:imcc:op not found 'index' (index<1>)

in file 'EVAL_1' line 42


if i read that correctly, it means i should stop coding, and start
installing tile in the kitchen. maybe somebody else has another take
on what's going on?

~jerry

Leopold Toetsch

unread,
May 14, 2005, 9:31:21 AM5/14/05
to perl6-i...@perl.org
Jerry Gay <parrotbug...@parrotcode.org> wrote:
> with parrot revision 8086, i'm running the following:

> .sub main @MAIN
> load_bytecode 'PGE.pbc'
> .local pmc p6rule, rulesub, match
> p6rule= find_global 'PGE', 'p6rule'
> rulesub= p6rule( '( \\ \. )+ \\' )
> .end


> which, under parrot -t, gives thousands of lines of output.
> eventually, i get the following...

> error:imcc:op not found 'index' (index<1>)

Inserting:

print $S0

before the C<compile> in P6Rule.pir:876 reveals the culprit:

$I0 = index "\", $S0

i.e. an unescapted backslash inside double quotes. OTOH there is also:

lit = '\\'

which should have double quotes to mean a single slash.

> ~jerry

leo

Patrick R. Michaud

unread,
May 14, 2005, 1:25:44 PM5/14/05
to Leopold Toetsch, perl6-i...@perl.org
On Sat, May 14, 2005 at 03:31:21PM +0200, Leopold Toetsch wrote:
> Jerry Gay <parrotbug...@parrotcode.org> wrote:
> > with parrot revision 8086, i'm running the following:
>
> > .sub main @MAIN
> > load_bytecode 'PGE.pbc'
> > .local pmc p6rule, rulesub, match
> > p6rule= find_global 'PGE', 'p6rule'
> > rulesub= p6rule( '( \\ \. )+ \\' )
> > .end
> > which, under parrot -t, gives thousands of lines of output.
> > eventually, i get the following...
> > error:imcc:op not found 'index' (index<1>)
>
> Inserting:
> print $S0
> before the C<compile> in P6Rule.pir:876 reveals the culprit:
> $I0 = index "\", $S0
> i.e. an unescapted backslash inside double quotes.

This particular bug is now fixed in r8102.

PGE is not yet complete in its handling of escape sequences
in literal strings -- there are just a lot of them to be handled.
For example:

rx / \n / # match a newline character (a character class)
rx / <"\n"> / # match a literal newline (probably \012)
rx / <'\n'> / # match a backslash + n

and for any literal string that PGE generates it must be sure that
it's properly escaped for PIR. (Fortunately this past week I found
Data::Escape which helps quite a bit.)

> OTOH there is also:
> lit = '\\'
> which should have double quotes to mean a single slash.

Hmmm, that seems odd. I looked in P6PE to find out about string
literal escapes and basically came away with "they work like Perl 5",
but occasionally I've noticed places where there's a mismatch...
such as this one. I couldn't find anything about string literals
in the Parrot docs -- is it documented somewhere?

Pm

Leopold Toetsch

unread,
May 15, 2005, 7:04:08 AM5/15/05
to Patrick R. Michaud, perl6-i...@perl.org
Patrick R. Michaud wrote:

> ... I couldn't find anything about string literals

> in the Parrot docs -- is it documented somewhere?

I've updated imcc/docs/syntax.pod yesterday with a small section
regarding string escapes. Baiscally inside double quoted strings the
usual escaping is done, inside single quotes no escapes are honored.

> Pm

leo

Reply all
Reply to author
Forward
0 new messages