The vm Package

uscheme implements a microscheme from Peter Norvig’s lis.py - this is the more primitive of the two versions. This isn’t a full Scheme, and in particular has the following caveats:

  1. The only types are symbols, ints, and floats.

  2. Function definition must be done via (define func (lambda ...)); doing (define func ...) will result in an error.

class graphbook.vm.uscheme.Interpreter(program: Optional[str] = None)[source]

A microscheme interpreter that maintains its own environment across runs.

eval(program: str) -> ((<class 'str'>, (<class 'int'>, <class 'float'>)), <class 'list'>)[source]

evaluate a microscheme program.

load_file(path)[source]

load the microscheme source file at path and evaluate it.

reset()[source]

reset the interpreter’s environment to the standard env.

graphbook.vm.uscheme.eval(exp, env)[source]

Evaluate an expression in an environment.

graphbook.vm.uscheme.expression_from_tokens(tokens: list) -> ((<class 'str'>, (<class 'int'>, <class 'float'>)), <class 'list'>)[source]

Given a list of tokens, return the first expression that was found.

graphbook.vm.uscheme.standalone(paths) → Any[source]

Standalone interpreter that will be run across the paths presented.

graphbook.vm.uscheme.standard_env()[source]

Return the standard environment.