Commits

Tohru Ike committed 83a7966

update document

  • Participants
  • Parent commits 4db8dff
  • Branches default

Comments (0)

Files changed (2)

 README
 =======
 
-Pure Python
--------------
+Translate
+-----------
 
-$ python ook.py <input>
+$ python ook.py <input ook file>
+$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py ook.py
+./ook-c <input ook file>
+$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py --opt=jit ook-jit.py
+./ook-jit-c <input ook file>
+$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py --opt=jit ook-jit2.py
+./ook-jit2-c <input ook file>
 
-RPython not contains JIT
+$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py --opt=jit ook-jit-debug.py
+./ook-jit-debug-c <input ook file>
+
+Run with output log file
 -------------------------
+PYPYLOG=<log file> ./ook-jit-debug-c <input ook file>
 
-$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py ook.py
+$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/logparser.py draw-time <log file> <output.png fike>
 
-RPython contains JIT
----------------------
 
-$ python ${PYPY_REPOSITORY_ROOT}/pypy/translator/goal/translate.py --opt=jit ook-jit.py
+java -noverify -jar sample-jvm.jar ../samples/hanoi.ook

File brainfuck2ook.py

-map = [
-    ["Ook!Ook.", "."],
-    ["Ook.Ook?", ">"],
-    ["Ook?Ook.", "<"],
-    ["Ook.Ook.", "+"],
-    ["Ook!Ook!", "-"],
-    ["Ook.Ook!", ","],
-    ["Ook!Ook?", "["],
-    ["Ook?Ook!", "]"]
-    ]
+map = {
+    ".": "Ook! Ook.",
+    ">": "Ook. Ook?",
+    "<": "Ook? Ook.",
+    "+": "Ook. Ook.",
+    "-": "Ook! Ook!",
+    ",": "Ook. Ook!",
+    "[": "Ook! Ook?",
+    "]": "Ook? Ook!"
+    }
 
 def convert(program):
-    for (after, before) in map:
-        program = program.replace(before, after)
-    print(program)
+    result = [map.get(char) for char in program if map.get(char)]
+    return ' '.join(result)
 
 def run(input):
     program = input.read()
-    convert(program)
+    codes = convert(program)
+    print codes
 
 if __name__ == '__main__':
     import sys