Commits

Anonymous committed 0ef8c40

fibonacci with stack overflow works

Comments (0)

Files changed (5)

example/fibonacci.spl

+#!/usr/bin/env perl
+use Lingua::Shakespeare;
+
+By Peter Nillius 2001-08-31
+<nillius at nada dot kth dot se>
+
+Fibonacci's numbers.
+
+Romeo, a lover with an accumulative memory.
+Juliet, a beautiful but domineering woman.
+Ulysses, a spaceman.
+
+
+                    Act I: A Minimalistic Play.
+
+                    Scene I: Juliet Sets Things Straight.
+
+[Enter Romeo and Juliet]
+
+Juliet:
+ You are nothing. Remember yourself.
+ You are the difference between nothing and a pig.
+ Open your heart!
+
+[Exit Romeo]
+
+[Enter Ulysses]
+
+Juliet:
+ You are the twice the square of the product of an stinking
+ goat and a fat pig. Speak your mind!
+
+                    Scene II: Accumulative Juggling.
+
+[Exit Ulysses]
+
+[Enter Romeo]
+
+Romeo:
+ You are me.
+
+Juliet:
+ Recall your inner most fears. You are the sum of me and thyself. 
+ Are you better than nothing?
+
+Romeo:
+ If not, we shall proceed to scene IV.
+
+Juliet:
+ Open your heart! Remember me.
+ 
+[Exit Romeo]
+
+                    Scene III: A Spaceman Interferes.
+
+[Enter Ulysses]
+
+Juliet:
+ Speak thy mind! 
+
+Ulysses:
+ We must return to Scene II.
+
+                    Scene IV: Romeo's head overflows.
+
+[Exeunt]

src/builtins/say.pir

 .end
 
 .sub 'dump'
-    .param pmc ary
-    .local pmc val
-    .local int i, size, status
+    .param pmc char
+    .local pmc val,ary
+    .local int i, v, size, status
+    .local string name
+    ary= char['list']
+    name = char['name']
     size = ary
   i=0
-  print "dump: "
+  print "\ndump "
+  print name
+  print ": v="
+  v= char['value']
+  print v
+  print " list=("
   loop:
     if i == size goto end_loop
     val = ary[0]
     i += 1
-    print "("
     print val
-    print ")"
+    print ","
   end_loop:
+    print ")\n"
 .end
 .sub 'find_other'
     .local int i, size, status

src/parser/grammar.pg

 grammar z2::Grammar is PCT::Grammar;
 
 rule TOP {
+  <shebang>?
   <title>
   <chardef>*
   <act>*
   {*}
 }
 
+rule shebang {
+  '#' \N*
+}
+
 rule title {
     <description> <end> 
 }
+#! foo
+
+ some title.
+ romeo, a prooving man.
+ Act I: fin.
+ Scene I: last.
+romeo: plan a king! proove a king!
 
 DIR=File.join(File.dirname(__FILE__),'..')
 
-puts "1..#{45+1+1+26+1+11}"
+puts "1..#{45+1+1+26+1+11+1}"
 def with_prog(name)
   p str= %W[../../parrot z2.pir example/#{name}.spl].map{|x| File.join(DIR,x)}*" "
   IO.popen(str,'r+') do |io|
     is o,x.strip
   end
 end
+with_prog 'fibonacci' do |prog|
+out = "1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903"
+  is out,prog.read(out.size)
+end
 __END__
 0
 1