Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
def load(context, code, filename):
    with open(filename.word, "r") as stream:
        code = LogoCompiler(stream).compile()
        code.run(context)