コード例 #1
0
ファイル: errors_ula.py プロジェクト: alansberman/Compiler
def main(argv):
    source_code_file = open(argv, "r")
    ans = lex_ula.main()
    if ans != None:
        print(ans)
    if ans == None:
        parse_ula.main()

    filename = argv[:-3]

    filename += "err"
    output = open(filename, "w")
    if ans != None:
        output.write(ans)
    output.close()
コード例 #2
0
def main():
    global result
    args = args_.manage_arguments()
    input_location = args.file_location[0]
    output_location = input_location.partition('.')[0]
    output_filename = output_location.split('/')[-1]

    # When lexing, ignore all comments and whitespace
    lex_ula.t_ignore_WHITESPACE = r'\s+'
    lex_ula.t_ignore_COMMENT = r'\/\*[^(\*\/);]+\*\/|\/\/.*'
    lex_ula.t_WHITESPACE = r'a^'
    lex_ula.t_COMMENT = r'a^'
    if (__name__ == "__main__"):
        output_location = output_filename + '.err'
        with open(output_location, 'w') as file_writer:
            lex_ula.main(file_writer)
            result = parse_ula.main(file_writer)
            apply_semantic_analysis(file_writer, result)
    else:
        lex_ula.main()
        result = parse_ula.main()
        apply_semantic_analysis(None, result)