From b72333948b85171f44fc196b2d0fb768d685fb58 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Wed, 19 Dec 2012 20:04:41 +0100 Subject: global var for default machine --- bytetunes.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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]) -- cgit v1.2.3