def run_script_text(dbn_script, **options): options = options or {} VERBOSE = options.get('verbose', False) dump_javascript = options.get('javascript', False) tokenizer = DBNTokenizer() parser = DBNParser() tokens = tokenizer.tokenize(dbn_script) if VERBOSE: for token in tokens: print token dbn_ast = parser.parse(tokens) if dump_javascript: print dbn_ast.to_js(varname='ast') if VERBOSE: dbn_ast.pprint() state = DBNInterpreterState() state = dbn_ast.apply(state) return state
def run_script_text(dbn_script, **options): options = options or {} VERBOSE = options.get('verbose', False) dump_javascript = options.get('javascript', False) tokenizer = DBNTokenizer() parser = DBNParser() tokens = tokenizer.tokenize(dbn_script) if VERBOSE: for token in tokens: print token dbn_ast = parser.parse(tokens) if dump_javascript: print dbn_ast.to_js(varname='ast') if VERBOSE: dbn_ast.pprint() state = DBNInterpreterState() state = dbn_ast.apply(state) return state
Set [X A] ((100 * A) / X) } } """ arithmetic_test_string = """ Set A (5 + 4 * 9) """ tokenizer = DBNTokenizer() parser = DBNParser() tokens = tokenizer.tokenize(repeat_test) for token in tokens: print token dbn_ast = parser.parse(tokens) dbn_ast.pprint() state = DBNInterpreterState() first_state = state state = dbn_ast.apply(state) output.draw_window(state.image._image)