Exemplo n.º 1
0
 def check_actions(self, actions, on_begin=True):
     actions = actions.replace(';', ';\n').split('\n')
     l = []
     if len(actions) > 2 and not on_begin:
         return '\nError in operands\n{}\nOperands begin before, end after operands expected'.format(
             actions)
     result = Token().analyzeCode(' '.join(actions))
     result = Token().combine_commands(result, [])
     for i in range(len(result)):
         try:
             err, num = Token().preview_command(result[i], i)
             return err.format(''.join(result[num]))
         except:
             l.append(' '.join(result[i]))
     return l
Exemplo n.º 2
0

result = Token().combine_commands(result, [])

#for i in result:
    #print(i)
    #print(' '.join(i))


if result[-1] == ['end.']:
    result = result[:-1]
    ident = 0
    for i in range(len(result)):
        try:
            err, num = Token().preview_command(result[i], i)
            print(err.format(' '.join(result[num])).replace('begin', ''))
            break
        except:
            ident += 1

    #if ident == len(result):
    #    print('Success!')

    #with open('code.py', 'r') as file:
    #    print(file.read())
    try:
        import code
        print('Main program:   b =', code.b)
        os.remove('/Users/lenasoroka/PycharmProjects/SP_RGR/code.py')
    except:
        pass