aboutsummaryrefslogtreecommitdiffstats
path: root/bytetunes.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-12-18 21:35:40 +0100
committerbnewbold <bnewbold@robocracy.org>2012-12-18 21:35:40 +0100
commitcd699af1e7d3e64556d2f9373db1d337cf14d2f5 (patch)
tree89e8c0ad4844a49a162ad96a12dbc9de6ba3e170 /bytetunes.py
parentcc6b87f6325f2138c387666d831e07ea7cfe7b1e (diff)
downloadbytetunes-cd699af1e7d3e64556d2f9373db1d337cf14d2f5.tar.gz
bytetunes-cd699af1e7d3e64556d2f9373db1d337cf14d2f5.zip
add more tests; cover ~~ case; fix bugs
Diffstat (limited to 'bytetunes.py')
-rwxr-xr-x[-rw-r--r--]bytetunes.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bytetunes.py b/bytetunes.py
index 1d2a8a7..8ed9641 100644..100755
--- a/bytetunes.py
+++ b/bytetunes.py
@@ -1,17 +1,25 @@
+#!/usr/bin/env python
from expr import *
import sys
def play(s):
- machine = parse(preparse(tokenize(s))[0])
+ machine = parse(preparse(tokenize(s)))
t = 0
while True:
t += 1
sys.stdout.write(chr(execute(machine, t) & 0x000000FF))
def main():
- play("(t>>6)&(2*t)&(t>>1)")
+ if len(sys.argv) <= 1:
+ play("(t>>6)&(2*t)&(t>>1)")
+ elif sys.argv[1] == '--test':
+ test_tokenize()
+ test_preparse()
+ test_parse()
+ else:
+ play(sys.argv[1])
if __name__=='__main__':
main()