def eval_file(file_name): f = codecs.open(file_name, encoding='utf-8') file_contents = f.read() program = Parser().parse(file_contents) context = ExecutionContext(dict((name, UNDEFINED) for name in program.get_declared_vars())) result = program.eval(context) return result.value, context
def eval_string(s, global_objects=None): if global_objects is None: global_objects = create_default_global_objects() # Parse file and create the execution context object program = Parser().parse(s) declared_vars = dict((name, UNDEFINED) for name in program.get_declared_vars()) declared_vars.update(global_objects) context = ExecutionContext(declared_vars) # Run code result = program.eval(context) return result.value, context
def eval_string(s, global_objects=None): if global_objects is None: global_objects = create_default_global_objects() # Parse file and create the execution context object program = Parser().parse(s) declared_vars = dict( ) #(name, UNDEFINED) for name in program.get_declared_vars()) declared_vars.update(global_objects) context = ExecutionContext(declared_vars) # Run code result = program.eval(context) return result.value, context
def setUpClass(cls): cls.parser = Parser(start='program')
def setUpClass(cls): cls.parser = Parser(start='statement')
def setUpClass(cls): cls.parser = Parser(start='expression')