Example #1
0
def p_fun_no_param(p):
    '''fun_no_param : ID DOT FUN_NO_PARAM LP RP '''

    p[0] = (p[3], p[1])
    global files

    if files.get(p[1]) is None:
        print(p)
        print(p[0])
        print(p[1])
        print(p[2])
        print(p[3])
        print(files)
        print("ID Error here", p[1])

        return p

    if p[3] == 'evaluate':
        if os.path.isdir(files[p[1]]):
            # print(files[p[1]])
            check_this(files[p[1]])

        elif files[p[1]].endswith('.c'):

            evaluate(files[p[1]], 'c')
        # elif files[p[1]].endswith('/'):
        #     print(files[p[1]])
    elif p[3] == "open":
        fileread(files[p[1]])

    elif p[3] == "show":
        if os.path.isdir(files[p[1]]):
            return show_this(files[p[1]])
        fileshow(files[p[1]])

    elif p[3] == 'eAll':
        print("evaluateAll")
        evaluateAll(files[p[1]])
        return

    elif p[3] == 'sAll':
        print("showAll")
        listAll = list()
        showAll(files[p[1]], listAll)
        print(listAll)
        return
def p_fun_single_param(p):
    '''fun_single_param : ID DOT FUN_SINGLE_PARAM LP STRING RP'''

    global files
    if files.get(p[1]) is None:
        print("ID Error")
        return p

    duplicatedpath = files[p[1]].copy()

    p[0] = (p[3], p[5])

    if p[3] == 'open':
        print('open')

        fileread(duplicatedpath)

    if p[3] == 'show':
        print('open')

        fileshow(duplicatedpath)
def p_fun_no_param(p):
    '''fun_no_param : ID DOT FUN_NO_PARAM LP RP '''

    p[0] = (p[3], p[1])
    global files

    if files.get(p[1]) is None:
        print("ID Error here", p[1])

        return p

    if p[3] == 'evaluate':
        #duplicatedpath = files[p[1]].copy()
        if files[p[1]].endswith('.c'):
            evaluate(files[p[1]], 'c')

    elif p[3] == "open":
        fileread(files[p[1]])

    elif p[3] == "show":
        fileshow(files[p[1]])