[pypy-svn] r45422 - pypy/extradoc/talk/dyla2007/demo

arigo at codespeak.net arigo at codespeak.net
Sat Jul 28 12:18:59 CEST 2007


Author: arigo
Date: Sat Jul 28 12:18:59 2007
New Revision: 45422

Added:
   pypy/extradoc/talk/dyla2007/demo/targettiny.py   (contents, props changed)
Log:
A translate target.


Added: pypy/extradoc/talk/dyla2007/demo/targettiny.py
==============================================================================
--- (empty file)
+++ pypy/extradoc/talk/dyla2007/demo/targettiny.py	Sat Jul 28 12:18:59 2007
@@ -0,0 +1,26 @@
+import tiny
+
+# __________  Entry point  __________
+
+def entry_point(argv):
+    if len(argv) < 2:
+        print "usage: tiny 'program' args..."
+        return 2
+    program = argv[1]
+    words = []
+    i = 0
+    while i < len(program):
+        j = program.find(' ', i)
+        if j < 0:
+            j = len(program)
+        if j > i:
+            words.append(program[i:j])
+        i = j + 1
+    res = tiny.interpret(words, [tiny.StrBox(s) for s in argv[2:]])
+    print res.as_str()
+    return 0
+
+# _____ Define and setup target ___
+
+def target(*args):
+    return entry_point, None



More information about the Pypy-commit mailing list