Beispiel #1
0
                    help='Arguments to pass to coqc; e.g., " -indices-matter" (leading and trailing spaces are stripped)')
parser.add_argument('--coqtop-args', metavar='ARG', dest='coqtop_args', type=str, nargs='?',
                    help='Arguments to pass to coqtop; e.g., " -indices-matter" (leading and trailing spaces are stripped)')
parser.add_argument('--coq_makefile', metavar='COQ_MAKEFILE', dest='coq_makefile', type=str, default='coq_makefile',
                    help='The path to the coq_makefile program.')
add_libname_arguments(parser)
add_logging_arguments(parser)

if __name__ == '__main__':
    args = process_logging_arguments(parser.parse_args())

    env = {
        'verbose': args.verbose,
        'log': args.log,
        'coqc': (args.coqc if args.coqbin == '' else os.path.join(args.coqbin, args.coqc)),
        'absolutize': args.absolutize,
        'as_modules': args.wrap_modules,
        'fast': args.fast_merge_imports,
        'coq_makefile': args.coq_makefile,
        'walk_tree': args.walk_tree
        }
    update_env_with_libnames(env, args)

    filename = args.input_file.name
    args.input_file.close()

    rtn = include_imports(filename, **env)

    args.output_file.write(rtn)
    args.output_file.close()
                re.findall(ALL_DEFINITIONS_STR % name, contents,
                           re.MULTILINE)))
    return contents


if __name__ == '__main__':
    args = process_logging_arguments(parser.parse_args())
    source = args.source
    env = {
        'lib_to_dir':
        lib_to_dir_map(args.libnames + args.non_recursive_libnames),
        'verbose': args.verbose,
        'log': args.log,
        'hide_reg': args.hide_reg
    }
    update_env_with_libnames(env, args)
    for theorem_id, suggestions in REG_PROOF_USING.findall('\n'.join(source)):
        all_suggestions = REG_SUB_PROOF_USING.findall(suggestions)
        suggestion = pick_suggestion(all_suggestions)
        filenames = list(reversed(split_to_file_and_rest(theorem_id, **env)))
        if filenames:
            is_first = True
            for filename, rest_id in filenames:
                orig = read_from_file(filename)
                updated = update_definitions(orig, filename, rest_id,
                                             suggestion, **env)
                if updated is not None:
                    if updated != orig:
                        if env['verbose'] >= 1:
                            env['log']('Updating %s in %s' %
                                       (rest_id, filename))
Beispiel #3
0
    env['remove_temp_file'] = False
    if env['temp_file_name'] == '':
        temp_file = tempfile.NamedTemporaryFile(suffix='.v', dir='.', delete=False)
        env['temp_file_name'] = temp_file.name
        temp_file.close()
        env['remove_temp_file'] = True

    if env['coqc_is_coqtop']:
        if env['coqc'] == 'coqc': env['coqc'] = env['coqtop']
        env['make_coqc'] = os.path.join(SCRIPT_DIRECTORY, 'coqtop-as-coqc.sh') + ' ' + env['coqc']

    coqc_help = get_coqc_help(env['coqc'], **env)
    coqc_version = get_coqc_version(env['coqc'], **env)

    if has_dir_binding(env['coqc_args'], coqc_help=coqc_help):
        update_env_with_libnames(env, args, default=tuple([]))
    else:
        update_env_with_libnames(env, args)

    for dirname, libname in env['libnames']:
        env['coqc_args'] = tuple(list(env['coqc_args']) + ['-R', dirname, libname])
    for dirname, libname in env['non_recursive_libnames']:
        env['coqc_args'] = tuple(list(env['coqc_args']) + ['-Q', dirname, libname])
    for dirname in env['ocaml_dirnames']:
        env['coqc_args'] = tuple(list(env['coqc_args']) + ['-I', dirname])
    env['coqc_args'] = deduplicate_trailing_dir_bindings(env['coqc_args'], coqc_help=coqc_help, coq_accepts_top=get_coq_accepts_top(env['coqc']))

    try:
        if env['verbose'] >= 1: env['log']('Listing identifiers...')
        unknown = []
        closed_idents = []
    env['remove_temp_file'] = False
    if env['temp_file_name'] == '':
        temp_file = tempfile.NamedTemporaryFile(suffix='.v', dir='.', delete=False)
        env['temp_file_name'] = temp_file.name
        temp_file.close()
        env['remove_temp_file'] = True

    if env['coqc_is_coqtop']:
        if env['coqc'] == 'coqc': env['coqc'] = env['coqtop']
        env['make_coqc'] = os.path.join(SCRIPT_DIRECTORY, 'coqtop-as-coqc.sh') + ' ' + env['coqc']

    coqc_help = get_coqc_help(env['coqc'], **env)
    coqc_version = get_coqc_version(env['coqc'], **env)

    if has_dir_binding(env['coqc_args'], coqc_help=coqc_help):
        update_env_with_libnames(env, args, default=tuple([]))
    else:
        update_env_with_libnames(env, args)

    for dirname, libname in env['libnames']:
        env['coqc_args'] = tuple(list(env['coqc_args']) + ['-R', dirname, libname])
    for dirname, libname in env['non_recursive_libnames']:
        env['coqc_args'] = tuple(list(env['coqc_args']) + ['-Q', dirname, libname])
    env['coqc_args'] = deduplicate_trailing_dir_bindings(env['coqc_args'], coqc_help=coqc_help, coq_accepts_top=get_coq_accepts_top(env['coqc']))

    try:
        if env['verbose'] >= 1: env['log']('Listing identifiers...')
        unknown = []
        closed_idents = []
        open_idents = []
        errors = []