# New Ticket Created by Moritz Lenz
# Please include the string: [perl #58452]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58452 >
Forwarding to [EMAIL PROTECTED] to open a ticket.
After applying the patch all tests except a codingstd test (trailing
whitespace) still pass, but since I'm not familiar with PGE I wait for
somebody else (Patrick?) to apply it. Instead I attached a version of
the patch without the trailing whitespace ;-)
Marcelo Serra Castilhos wrote:
> While writing something like a LISP reader I found this bug. To replicate it
> this is enough:
>
> proto prefix:<'> is looser('term:') { ... }
>
> The problem is that the ' in the name of the operators aren't escaped.
>
> The patch I attached uses library/Data/Escape.pbc to escape the names. The
> only modified file is
> runtime/parrot/library/PGE/Perl6Grammar.pir
A test for that would be nice.
Moritz
--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/
Index: runtime/parrot/library/PGE/Perl6Grammar.pir
===================================================================
--- runtime/parrot/library/PGE/Perl6Grammar.pir (revision 30633)
+++ runtime/parrot/library/PGE/Perl6Grammar.pir (working copy)
@@ -73,6 +73,7 @@
load_bytecode 'PGE/Text.pbc'
load_bytecode 'PGE/Util.pbc'
load_bytecode 'PCT/HLLCompiler.pbc'
+ load_bytecode 'library/Data/Escape.pbc'
.local pmc p6regex
p6regex = compreg 'PGE::Perl6Regex'
@@ -339,6 +340,9 @@
$P0 = nstable[namespace]
optable = $P0['optable']
+ ## Escape function
+ .local pmc esc
+ esc = find_global "Data::Escape", "String"
## build the list of traits
.local pmc iter
.local string traitlist
@@ -366,8 +370,10 @@
goto trait_sub
trait_arg:
if trait == 'parsed' goto trait_sub
- arg = concat "'", arg
- arg = concat arg, "'"
+ ## Escape the arg
+ arg = esc (arg)
+ arg = concat '"', arg
+ arg = concat arg, '"'
goto trait_arg_done
trait_sub:
optable.emit(" $P0 = get_hll_global ['%0'], '%1'", namespace, arg)
@@ -382,7 +388,10 @@
concat traitlist, arg
goto trait_loop
trait_end:
- optable.emit(" optable.newtok('%0'%1)", name, traitlist)
+ ## Escape the name
+ $P0 = find_global "Data::Escape", "String"
+ name = $P0(name, '"')
+ optable.emit(" optable.newtok(\"%0\"%1)", name, traitlist)
.return ()
.end