def __init__(self, turtle): self.root = RootContext() self.turtle = turtle self.stream = StringStream() self.compiler = LogoCompiler(self.stream) for b in builtin_list: self.root.add_builtin(b)
class Logo(object): def __init__(self, turtle): self.root = RootContext() self.turtle = turtle self.stream = StringStream() self.compiler = LogoCompiler(self.stream) for b in builtin_list: self.root.add_builtin(b) def run(self, text): self.stream.append(text) while self.stream: code = self.compiler.compile_line() code.run(self.root) def _setturtle(self, turtle): self._turtle = turtle self.root.turtle = turtle def _getturtle(self, turtle): return self._turtle turtle = property(_getturtle, _setturtle)
def load(context, code, filename): with open(filename.word, "r") as stream: code = LogoCompiler(stream).compile() code.run(context)