Example #1
0
def read_eval_print(env_pairs_string, prompt=None):
    from sys import exit
    from types import FunctionType
    from mnpeval import eval_, eval_adding_alist
    from mnpread import string_to_expr
    import traceback

    try:
        a = None
        if len(env_pairs_string) > 0:
            a = string_to_expr(env_pairs_string)[0]
        x = read_exprs(prompt=prompt)

        for xi in x:
            if a != None:
                yi = eval_adding_alist(xi, alist=a)
            else:
                yi = eval_(xi)
            if yi != None and str(yi) != '' \
                    and not isinstance(yi, FunctionType):
                print(yi)
    except EOFError:
        exit(0)
    except StopIteration:
        print(StopIteration)
    except Exception:
        traceback.print_exc()
Example #2
0
def read_eval_print(env_pairs_string, prompt=None):
    from sys import exit
    from types import FunctionType
    from mnpeval import eval_, eval_adding_alist
    from mnpread import string_to_expr
    import traceback

    try:
        a = None
        if len(env_pairs_string) > 0:
            a = string_to_expr(env_pairs_string)[0]
        x = read_exprs(prompt=prompt)

        for xi in x:
            if a != None:
                yi = eval_adding_alist(xi, alist=a)
            else:
                yi = eval_(xi)
            if yi != None and str(yi) != '' \
                    and not isinstance(yi, FunctionType):
                print yi
    except EOFError:
        exit(0)
    except StopIteration:
        print StopIteration
    except Exception:
        traceback.print_exc()
Example #3
0
def main():
    from sys import stdin
    from mnpread import string_to_expr

    x = string_to_expr(stdin.read())

    for xi in x:
        compile_expr(xi)
Example #4
0
def read_exprs(prompt=None):
    from sys import stdin
    from mnpread import read_next_exprs, string_to_expr

    if prompt == None:
        x = string_to_expr(stdin.read())  # input from file
    else:
        x = read_next_exprs(prompt=prompt)  # interactive prompt
    return x
Example #5
0
def read_exprs(prompt=None):
    from sys import stdin
    from mnpread import read_next_exprs, string_to_expr

    if prompt == None:
        x = string_to_expr(stdin.read())  # input from file
    else:
        x = read_next_exprs(prompt=prompt)  # interactive prompt
    return x