interpreter for pylogo
Ian Bicking <>

A Logo interpreter.




a Logo

<RootFrame -48c0bcf4>

a StringTypes

(<type 'str'>, <type 'unicode'>)


f arity(func) ...

Get the arity of a function (the number of arguments it takes). If the function has an arity attribute, this will be used as an override, otherwise inspect is used to find the number of arguments.

Since logo_aware functions take an interpreter as the first argument, the arity of these functions is reduced by one.

f load_module(name, path=None) ...

Loads a module given its name, because imp.find_module is annoying.


C Interpreter(...) ...

The interpreter gets tokens (from a reader.TrackingStream) and runs them. It holds the namespace, which is dynamically scoped.

You execute one expression by calling interpreter.expr(tokenizer), where tokenizer may be reader.TrackingStream or other tokenizer instance. It returns the value of the expression.

The RootFrame and Frame subclasses implement the namespace operations (this class is abstract).

This class contains 31 members.

C UserFunction(...) ...

A function the user defines, using TO. When this function is called, the contents of the TO statement are executed. The contents are not interpreted until then -- they are kept as tokens in a list.

This class contains 3 members.

C BoundUserFunction(...) ...

This class contains 3 members.

C RootFrame(...) ...

The root/global frame object. This holds all the function definitions, and global variables. All the algorithms end up being different than for Frame, so they don't even inherit from each other, though they present the same interface. Huh.

This class contains 44 members.

C Frame(...) ...

A local frame. This frame usually has a parent frame, which is the scope that created this scope (usually via a function call). This chain implements the dynamic scoping; in a more typical lexically scoped language, the namespace would be attached to the container, not the previous caller.

Lisps sometimes implement both of these policies (fluid-wind?), where certain variables are dynamic (usually marked like this), but other variables are lexical. That might be neat.

This class contains 44 members.

See the source for more information.