# New Ticket Created by  Jerome Quelin 
# Please include the string:  [perl #19626]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19626 >


> Because what I said I'd really like (apart from "moon on a stick",
> "a new apocalypse" (and "a pony", which Jerome had to remind me
> about)) would be a compiler that reads in Ook!, creates parrot
> bytecode on the fly, and then calls it, without using temporary
> files.

I can't imagine how you could forget to ask for a pony... :-)


> However, when I tried compiling my Ook! test program:
[... Nice Ook! program skipped ...]
> I got this:
> Label KOO1_2 already exists at ../../assemble.pl line 557.

Uh, yes... The previous implementation was a little naive with 
multi-level while nested. The patch attached fixes that with a new 
naming scheme for the labels generated, alowing as many nesting levels 
and as many while in a row in whatever order you want (hopefully).
I also added your test.ook file (if you allow me to ship it) in order 
for other people to play with. If you're ok with it, please add it to 
the MANIFEST file (laziness reasons made me diffing only the ook 
directory). Thanks.

Oh, btw. This patch assumes the first Ook! patch is already commited.

Jerome
-- 
[EMAIL PROTECTED]


-- attachment  1 ------------------------------------------------------
url: 
http://rt.perl.org/rt2/attach/46638/36636/906ac0/ook_use_array_for_multilevel_while.patch

diff -urbN ook.old/Changes ook/Changes
--- ook.old/Changes	2002-12-31 16:57:58.000000000 +0100
+++ ook/Changes	2002-12-31 18:02:53.000000000 +0100
@@ -1,5 +1,13 @@
 Revision history for a Ook! compiler written in Parrot and targeting Parrot.
 
+0.0.2 Tue Dec 31 18:02:01 CET 2002
+        - Nicholas Clark reported a bug when there's a complex nesting
+          of while instructions in the ook source. This version fixes
+          it with a brand new scheme of naming the labels in the
+          generated Parrot assembly.
+        - added a test.ook file that illustrates the old bug, and
+          works as Test::Harness expects.
+
 0.0.1 Mon Dec 30 23:46:32 CET 2002
         - thanks to a silly idea of Nicholas Clark, first draft of this
           Ook! compiler written in Parrot.
diff -urbN ook.old/ook.pasm ook/ook.pasm
--- ook.old/ook.pasm	2002-12-31 18:05:59.000000000 +0100
+++ ook/ook.pasm	2002-12-31 18:07:04.000000000 +0100
@@ -11,13 +11,12 @@
 EOF:
         close P0
 
-        
 # Then, parse it to translate it.
         length I0, S1       # Total length of file.
         set I1, 0           # Char number in the file.
         set I2, 1           # Line number (for error reporting).
-        set I6, 0           # While-level (iterate).
-        set I7, 0           # While-level (nested).
+        new P1, .PerlArray  # While-level.
+        push P1, 0
         set S2, ""          # Current char.
         set S3, ""          # Current instruction.
         set S4, "\tnew P0,.PerlArray\n\tset I0,0\n"       # Code generated.
@@ -55,41 +54,27 @@
         branch LOOP_END
 LOOP_NOT_DEC:
         ne S3, "Ook!Ook?", LOOP_NOT_WHILE
-        inc I7
+        bsr MAKE_LABEL
         concat S4, "\tbranch OOK"
-        set S5, I6
-        concat S4, S5
-        concat S4, "_"
-        set S5, I7
-        concat S4, S5
+        concat S4, S6
         concat S4, "\nKOO"
-        set S5, I6
-        concat S4, S5
-        concat S4, "_"
-        set S5, I7
-        concat S4, S5
+        concat S4, S6
         concat S4, ":\n"
+        push P1, 0
         set S3, ""
         branch LOOP_END
 LOOP_NOT_WHILE:
         ne S3, "Ook?Ook!", LOOP_NOT_ELIHW
+        pop I10, P1
+        bsr MAKE_LABEL
         concat S4, "OOK"
-        set S5, I6
-        concat S4, S5
-        concat S4, "_"
-        set S5, I7
-        concat S4, S5
+        concat S4, S6
         concat S4, ":\n\tset I1,P0[I0]\n\tne I1,0,KOO"
-        set S5, I6
-        concat S4, S5
-        concat S4, "_"
-        set S5, I7
-        concat S4, S5
+        concat S4, S6
         concat S4, "\n"
-        dec I7
-        ne I7, 0, LOOP_NESTING_DONE
-        inc I6
-LOOP_NESTING_DONE:      
+        pop I7, P1
+        inc I7
+        push P1, I7
         set S3, ""
         branch LOOP_END
 LOOP_NOT_ELIHW:
@@ -118,3 +103,21 @@
         concat S4, "\tend\n"
         print S4
         end
+
+# Given the content of P1, create a label of integers concateneted in S6.
+MAKE_LABEL:
+        set I10, P1
+        set I11, 0
+        set S6, ""
+        branch LABEL_END
+LABEL_LOOP:
+        concat S6, "_"
+        set I12, P1[I11]
+        set S7, I12
+        concat S6, S7
+        inc I11
+LABEL_END:
+        lt I11, I10, LABEL_LOOP
+        ret
+                
+
diff -urbN ook.old/test.ook ook/test.ook
--- ook.old/test.ook	1970-01-01 01:00:00.000000000 +0100
+++ ook/test.ook	2002-12-31 16:59:14.000000000 +0100
@@ -0,0 +1,28 @@
+Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
+Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
+Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook. Ook? Ook! Ook? Ook. Ook?
+Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook!
+Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook!
+Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook. Ook? Ook. Ook?
+Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook? Ook.
+Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook! Ook! Ook! Ook! Ook! Ook? Ook.
+Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook.
+Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook?
+Ook! Ook. Ook. Ook? Ook. Ook? Ook! Ook. Ook! Ook. Ook? Ook. Ook? Ook.
+Ook! Ook. Ook? Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook! Ook? Ook. Ook?
+Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
+Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook?
+Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
+Ook. Ook? Ook. Ook? Ook! Ook! Ook! Ook? Ook? Ook. Ook. Ook. Ook? Ook.
+Ook? Ook. Ook. Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook!
+Ook? Ook. Ook! Ook. Ook? Ook. Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook!
+Ook! Ook! Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook.
+Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook? Ook. Ook.
+Ook. Ook. Ook? Ook. Ook? Ook. Ook! Ook? Ook. Ook? Ook! Ook? Ook. Ook?
+Ook! Ook? Ook. Ook? Ook. Ook. Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook.
+Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook?
+Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook?
+Ook. Ook? Ook. Ook? Ook! Ook? Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook.
+Ook. Ook? Ook. Ook? Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook? Ook.
+Ook? Ook. Ook? Ook. Ook! Ook! Ook? Ook! Ook. Ook? Ook! Ook. Ook? Ook.
+Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook? Ook. Ook! Ook.

Reply via email to