Beispiel #1
0
def setup_globals(names):
    if not isinstance(names, list): names = [names]

    global next_global
    for x in names:
        ts.init('( gread ' + str(next_global) + ')');
        getter = ts.intern(str(x))
        getter.macro = ts.readList()
        setter = ts.intern('set' + str(x))
        ts.init('gwrite ' + str(next_global))
        setter.macro = ts.readList()
        next_global += 1
Beispiel #2
0
def setup_globals(names):
    if not isinstance(names, list): names = [names]

    global next_global
    for x in names:
        ts.init('( gread ' + str(next_global) + ')')
        getter = ts.intern(str(x))
        getter.macro = ts.readList()
        setter = ts.intern('set' + str(x))
        ts.init('gwrite ' + str(next_global))
        setter.macro = ts.readList()
        next_global += 1
Beispiel #3
0
def pass1_fcn(name, args, body):
    if 'type' in name.__dict__: raise ValueError(str(name) + " already defined")
    add((name, args, body))
    name.args = len(args)
    name.argnames = args
    name.type = 'ufun'
    name.outputs = mmmember(ts.intern('output'), body)
Beispiel #4
0
def pass1_fcn(name, args, body):
    if 'type' in name.__dict__:
        raise ValueError(str(name) + " already defined")
    add((name, args, body))
    name.args = len(args)
    name.argnames = args
    name.type = 'ufun'
    name.outputs = mmmember(ts.intern('output'), body)
Beispiel #5
0
def handle_waituntil():
    add_and_count(['-[-', 0], 3)
    newbody = state.body.pop(0)
    oldbody, state.body = state.body, newbody
    pass2_argloop(1, 'waituntil')
    add_and_count(['-]-r', 0], 1)
    add_and_count(['prim', ts.intern('waituntil')], 1)
    state.body = oldbody
Beispiel #6
0
def handle_waituntil():
    add_and_count(['-[-', 0], 3)
    newbody = state.body.pop(0)
    oldbody, state.body = state.body, newbody
    pass2_argloop(1, 'waituntil')
    add_and_count(['-]-r', 0], 1)
    add_and_count(['prim', ts.intern('waituntil')], 1)
    state.body = oldbody
Beispiel #7
0
def setup_specials(*newprims):
    for x in newprims:
        name, outputs, handler = x
        sym = ts.intern(name)
        sym.type = 'prim'
        sym.args = 0
        sym.outputs = outputs
        sym.special = True
        sym.handler = handler
Beispiel #8
0
def setup_specials(*newprims):
    for x in newprims:
        name, outputs, handler = x
        sym = ts.intern(name)
        sym.type = 'prim'
        sym.args = 0
        sym.outputs = outputs
        sym.special = True
        sym.handler = handler
Beispiel #9
0
def setup_prims(primtype, dest, *newprims):
    for x in newprims:
        name, outputs, args = x
        sym = ts.intern(name)
        sym.args = args
        sym.outputs = outputs
        if sym.args < 0: infixes.append(sym)
        sym.type = primtype
        sym.special = False
        dest.append(sym)
Beispiel #10
0
def setup_prims(primtype, dest, *newprims):
    for x in newprims:
        name, outputs, args = x
        sym = ts.intern(name)
        sym.args = args
        sym.outputs = outputs
        if sym.args < 0: infixes.append(sym)
        sym.type = primtype
        sym.special = False
        dest.append(sym)
Beispiel #11
0
def pass2_fcn(fcn):
    global state
    state = record()
    state.toplevel = True
    state.command = True
    state.body = []
    state.locals = []

    state.name, state.arglist, body = fcn

    state.name.addr = pc
    state.name.locals = 0
    add_and_count(['to', state.name], 2)
    pass2_body(body[:])
    add_and_count(['prim', ts.intern('stop')], 1)
    state.name.endaddr = pc
Beispiel #12
0
def pass2_fcn(fcn):
    global state
    state = record()
    state.toplevel = True
    state.command = True
    state.body = []
    state.locals = []

    state.name, state.arglist, body = fcn

    state.name.addr = pc
    state.name.locals = 0
    add_and_count(['to', state.name], 2)
    pass2_body(body[:])
    add_and_count(['prim', ts.intern('stop')], 1)
    state.name.endaddr = pc
Beispiel #13
0
def sym(x):
    if not isinstance(x, ts.symbol) and not isinstance(x, ts.qsym):
        raise LogoError(mmstr(x) + " isn't a valid local")
    return ts.dsym(ts.intern(str(x)))
Beispiel #14
0
def handle_opening():
    pass2_argloop(1, ')')
    if [] == state.body or state.body.pop(0) != ts.intern(')'):
        raise LogoError('() error')
Beispiel #15
0
def sym(x):
    if not isinstance(x, ts.symbol) and not isinstance(x, ts.qsym):
        raise LogoError(mmstr(x) + " isn't a valid local")
    return ts.dsym(ts.intern(str(x)))
Beispiel #16
0
def handle_opening():
    pass2_argloop(1, ')')
    if [] == state.body or state.body.pop(0) != ts.intern(')'): raise LogoError('() error')