diff options
author | bnewbold <bnewbold@robocracy.org> | 2012-12-19 20:04:41 +0100 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2012-12-19 20:04:41 +0100 |
commit | b72333948b85171f44fc196b2d0fb768d685fb58 (patch) | |
tree | f2caa34abcf9a3d00fccc647f914b5c965e49d85 | |
parent | ff3a4e3ee0c27c38ca9a63a4fe6fe54221687e91 (diff) | |
download | bytetunes-b72333948b85171f44fc196b2d0fb768d685fb58.tar.gz bytetunes-b72333948b85171f44fc196b2d0fb768d685fb58.zip |
global var for default machine
-rwxr-xr-x | bytetunes.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bytetunes.py b/bytetunes.py index 8ed9641..597ef3a 100755 --- a/bytetunes.py +++ b/bytetunes.py @@ -4,6 +4,8 @@ from expr import * import sys +DEFAULT = "(t>>6)&(2*t)&(t>>1)" + def play(s): machine = parse(preparse(tokenize(s))) t = 0 @@ -13,11 +15,16 @@ def play(s): def main(): if len(sys.argv) <= 1: - play("(t>>6)&(2*t)&(t>>1)") + play(DEFAULT) elif sys.argv[1] == '--test': test_tokenize() test_preparse() test_parse() + elif sys.argv[1] == '--parse': + if len(sys.argv) < 3: + print strmachine(parse(preparse(tokenize(DEFAULT)))) + else: + print strmachine(parse(preparse(tokenize(sys.argv[2])))) else: play(sys.argv[1]) |