# Path: pigeon/xerblin/btree.py
# def fill_tree(node, items):
#     '''
#     Add the (key, value) pairs in items to a btree in a balanced way.
# 
#     You can balance a tree like so:
# 
#         tree = fill_tree((), items(tree))
# 
#     This iterates through the tree and returns a new, balanced tree from
#     its contents.
#     '''
#     for key, value in _yield_balanced(sorted(items)):
#         node = insert(node, key, value)
#     return node
# 
# def items(node):
#     '''
#     Iterate in order over the (key, value) pairs in a tree.
#     '''
#     if not node:
#         return
# 
#     key, value, lower, higher = node
#     
#     for kv in items(lower):
#         yield kv
#     
#     yield key, value
#     
#     for kv in items(higher):
#         yield kv
# 
# Path: pigeon/xerblin/library.py
# def assemble((stack, dictionary)):
# def compile((stack, dictionary)):
# def dup((stack, dictionary)):
# def swap((stack, dictionary)):
# def pick((stack, dictionary)):
# def tuck((stack, dictionary)):
# def drop((stack, dictionary)):
# def over((stack, dictionary)):
# def lookup(interpreter):
# def inscribe((stack, dictionary)):
# def NewSeqWord((stack, dictionary)):
# def NewLoopWord((stack, dictionary)):
# def NewBranchWord((stack, dictionary)):
# def NewEnstackener((stack, dictionary)):
# def add((stack, dictionary)):
# def sub((stack, dictionary)):
# def mul((stack, dictionary)):
# def pickle(interpreter):
# def unpickle(interpreter):
# def rebalance((stack, dictionary)):
# def view(interpreter):
# def listwords(interpreter):
#     HEX = assemble_raw(source)
# 
# Path: pigeon/xerblin/base.py
# def interpret(I, command):
#     '''
#     Given an interpreter and a string command, interpret that string on
#     the interpreter and return the modified interpreter.
#     '''
#     for word in command:
# 
#         # Is it an integer?
#         try:
#             literal = int(word)
#         except ValueError:
# 
#             # Is it a float?
#             try:
#                 literal = float(word)
#             except ValueError:
# 
#                 # Is it a string literal?
#                 if word.startswith('"') and word.endswith('"'):
#                     literal = word[1:-1]
# 
#                 # Nope, it must be a command word.
#                 else:
#                     # Interpret the word.
#                     func = get(I[1], word)
#                     I = apply_func(I, func)
#                     continue
# 
#         # A literal was found, push it onto the stack.
#         I = (literal, I[0]), I[1]
# 
#     return I


import pickle, pprint, StringIO, os
from pigeon.xerblin.btree import fill_tree, items
from pigeon.xerblin.library import words
from pigeon.xerblin.base import interpret
    from xerblin.btree import items
You can pass a file name or open file object to the World as its
save_file argument and that will be used to save the pickle data as
you use the World object, but other than that you're on your own.

Code Documentation
^^^^^^^^^^^^^^^^^^

'''


def view0(I):
    '''Print the stack to stdout with python's default formatting.'''
    print repr(I[0])
    print


def view1(I):
    '''Print the stack to stdout using the pprint module.'''
    pprint.pprint(I[0])
    print


def nullView(I):
    '''"Do nothing" view.'''
    pass


# An initial interpreter to use for spawning worlds.  It has an empty
# stack and whatever commands are defined by default in the library
# module.

# Path: pigeon/xerblin/btree.py
# def fill_tree(node, items):
#     '''
#     Add the (key, value) pairs in items to a btree in a balanced way.
# 
#     You can balance a tree like so:
# 
#         tree = fill_tree((), items(tree))
# 
#     This iterates through the tree and returns a new, balanced tree from
#     its contents.
#     '''
#     for key, value in _yield_balanced(sorted(items)):
#         node = insert(node, key, value)
#     return node
# 
# def items(node):
#     '''
#     Iterate in order over the (key, value) pairs in a tree.
#     '''
#     if not node:
#         return
# 
#     key, value, lower, higher = node
#     
#     for kv in items(lower):
#         yield kv
#     
#     yield key, value
#     
#     for kv in items(higher):
#         yield kv
# 
# Path: pigeon/xerblin/library.py
# def assemble((stack, dictionary)):
# def compile((stack, dictionary)):
# def dup((stack, dictionary)):
# def swap((stack, dictionary)):
# def pick((stack, dictionary)):
# def tuck((stack, dictionary)):
# def drop((stack, dictionary)):
# def over((stack, dictionary)):
# def lookup(interpreter):
# def inscribe((stack, dictionary)):
# def NewSeqWord((stack, dictionary)):
# def NewLoopWord((stack, dictionary)):
# def NewBranchWord((stack, dictionary)):
# def NewEnstackener((stack, dictionary)):
# def add((stack, dictionary)):
# def sub((stack, dictionary)):
# def mul((stack, dictionary)):
# def pickle(interpreter):
# def unpickle(interpreter):
# def rebalance((stack, dictionary)):
# def view(interpreter):
# def listwords(interpreter):
#     HEX = assemble_raw(source)
# 
# Path: pigeon/xerblin/base.py
# def interpret(I, command):
#     '''
#     Given an interpreter and a string command, interpret that string on
#     the interpreter and return the modified interpreter.
#     '''
#     for word in command:
# 
#         # Is it an integer?
#         try:
#             literal = int(word)
#         except ValueError:
# 
#             # Is it a float?
#             try:
#                 literal = float(word)
#             except ValueError:
# 
#                 # Is it a string literal?
#                 if word.startswith('"') and word.endswith('"'):
#                     literal = word[1:-1]
# 
#                 # Nope, it must be a command word.
#                 else:
#                     # Interpret the word.
#                     func = get(I[1], word)
#                     I = apply_func(I, func)
#                     continue
# 
#         # A literal was found, push it onto the stack.
#         I = (literal, I[0]), I[1]
# 
#     return I


# Path: pigeon/xerblin/world.py
import pickle, pprint, StringIO, os
from pigeon.xerblin.btree import fill_tree, items
from pigeon.xerblin.library import words
from pigeon.xerblin.base import interpret
    from xerblin.btree import items

You can pass a file name or open file object to the World as its
save_file argument and that will be used to save the pickle data as
you use the World object, but other than that you're on your own.

Code Documentation
^^^^^^^^^^^^^^^^^^

'''


def view0(I):
    '''Print the stack to stdout with python's default formatting.'''
    print repr(I[0])
    print


def view1(I):
    '''Print the stack to stdout using the pprint module.'''
    pprint.pprint(I[0])
    print


def nullView(I):
    '''"Do nothing" view.'''
    pass


# An initial interpreter to use for spawning worlds.  It has an empty
# stack and whatever commands are defined by default in the library
# module.

ROOT = (), fill_tree((), words)