Beispiel #1
0
    print('Parable Listener, (c) 2013-2016 Charles Childers')
    print('------------------------------------------------')
    print('.s       Display Stack')
    print('bye      Exit Listener')
    print('words    Display a list of all named items')
    print('------------------------------------------------\n')

    readline.set_completer(completer)
    readline.parse_and_bind("tab: complete")

    parable.prepare_slices()
    parable.prepare_dictionary()
    if os.path.exists('parable.snapshot'):
        init_from_snapshot(open('parable.snapshot').read())
    else:
        parable.parse_bootstrap(open('stdlib.p').readlines())

    evaluate("[ \"-\"   `9000 ] '.s' :")
    evaluate("[ \"-\"   `9001 ] 'bye' :")
    evaluate("[ \"-\"   `9002 ] 'words' :")
    evaluate("[ \"s-\"  `9003 ] 'include' :")

    try:
        home = expanduser("~")
        src = home + "/.parable/on_startup.p"
        parable.parse_bootstrap(open(src).readlines())
    except:
        pass

    while 1 == 1:
        try:
Beispiel #2
0
    options = [x for x in parable.dictionary_names if x.startswith(text)]
    try:
        return options[state]
    except IndexError:
        return None


if __name__ == '__main__':
    (width, height) = getTerminalSize()

    readline.set_completer(completer)
    readline.parse_and_bind("tab: complete")

    parable.prepare_slices()
    parable.prepare_dictionary()
    parable.parse_bootstrap(open('stdlib.p').readlines())

    try:
        home = expanduser("~")
        src = home + "/.parable/on_startup.p"
        parable.parse_bootstrap(open(src).readlines())
    except:
        pass

    while 1 == 1:
        display(height, width)

        try:
            src = get_input()
        except:
            sys.stdout.write("\n")
Beispiel #3
0
def opcode_include_file():
    import os
    name = parable.slice_to_string(parable.stack_pop())
    if os.path.exists(name):
        source = open(name).readlines()
        parable.parse_bootstrap(source)
Beispiel #4
0
                i += 1
            new = new + '"'
        else:
            new = new + " " + token
        i += 1
    return new


def evaluate(s):
    parable.interpret(parable.compile(s, parable.request_slice()))

if __name__ == '__main__':
    print 'Amoeba, Copyright (c) 2013-2016 Charles Childers\n'
    parable.prepare_slices()
    parable.prepare_dictionary()
    parable.parse_bootstrap(open('stdlib.p').readlines())
    parable.parse_bootstrap(open('amoeba.p').readlines())

    while 1 == 1:
        sys.stdout.write("\nok ")
        sys.stdout.flush()

        src = sys.stdin.readline()

        if len(src) > 1:
            t = rewrite(src)
            print 'translate>> ' + t
            slice = parable.request_slice()
            parable.interpret(parable.compile(t, slice), opcodes)

        for e in parable.errors:
Beispiel #5
0
def opcode_include_file():
    import os
    name = parable.slice_to_string(parable.stack_pop())
    if os.path.exists(name):
        source = open(name).readlines()
        parable.parse_bootstrap(source)
Beispiel #6
0
def load_files(files):
    for i in files:
        if os.path.exists(i) and i != "./gen-snapshot.py" and i != "gen-snapshot.py" :
            parable.parse_bootstrap(open(i).readlines())
Beispiel #7
0
def prepare():
    parable.prepare_slices()
    parable.prepare_dictionary()
    parable.parse_bootstrap(open('stdlib.p').readlines())