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



Index: runtime/parrot/library/PGE/Perl6Grammar.pir
===================================================================
--- runtime/parrot/library/PGE/Perl6Grammar.pir	(revision 30618)
+++ runtime/parrot/library/PGE/Perl6Grammar.pir	(working copy)
@@ -73,7 +73,8 @@
     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
 

Reply via email to