Пример #1
0
def test(asmfile):
    lexer = Lexer(asmfile)
    parser = Parser(lexer)
    prog = parser.parse()
    prog.solve_labels()
    mcode = prog.machine_code()
    return mcode
Пример #2
0
def test_errors(asm):
    lexer = Lexer(asm)
    parser = Parser(lexer)

    # -- Syntax analysis
    try:
        prog = parser.parse()
    except Exception as inst:
        msg, = inst.args
        return msg

    # -- Semantic analysis
    try:
        prog.solve_labels()
    except Exception as inst:
        msg, = inst.args
        return msg