예제 #1
0
파일: versioning.py 프로젝트: turboza/quark
def compiler_version_spec_messages(file_nodes):
    for file in file_nodes:
        assert isinstance(file, ast.File)
        compiler_version_spec_nodes = [
            node for node in file.children
            if isinstance(node, ast.CompilerVersionSpec)
        ]
        if compiler_version_spec_nodes == []:
            yield Warning(
                messages.version_spec_missing(
                    location=lineinfo(file),
                    compiler_version=COMPILER_VERSION,
                ))
        if len(compiler_version_spec_nodes) >= 2:
            yield Error(
                messages.too_many_version_specs(
                    first_location=lineinfo(compiler_version_spec_nodes[0]),
                    second_location=lineinfo(compiler_version_spec_nodes[1]),
                ))
        for node in compiler_version_spec_nodes:
            if not node.strict:
                yield Error(
                    messages.version_spec_malformed(
                        location=lineinfo(node),
                        compiler_version=COMPILER_VERSION,
                    ))
            errors = version_spec_string_messages(
                spec_string=node.spec_string,
                location=lineinfo(node),
            )
            for error in errors:
                yield error
예제 #2
0
def compiler_version_spec_messages(file_nodes):
    for file in file_nodes:
        assert isinstance(file, ast.File)
        compiler_version_spec_nodes = [
            node for node in file.children
            if isinstance(node, ast.CompilerVersionSpec)
        ]
        if compiler_version_spec_nodes == []:
            yield Warning(messages.version_spec_missing(
                location=lineinfo(file),
                compiler_version=COMPILER_VERSION,
            ))
        if len(compiler_version_spec_nodes) >= 2:
            yield Error(messages.too_many_version_specs(
                first_location=lineinfo(compiler_version_spec_nodes[0]),
                second_location=lineinfo(compiler_version_spec_nodes[1]),
            ))
        for node in compiler_version_spec_nodes:
            if not node.strict:
                yield Error(messages.version_spec_malformed(
                    location=lineinfo(node),
                    compiler_version=COMPILER_VERSION,
                ))
            errors = version_spec_string_messages(
                spec_string=node.spec_string,
                location=lineinfo(node),
            )
            for error in errors:
                yield error
예제 #3
0
def version_spec_string_messages(spec_string, location):
    version = Version.parse(spec_string)

    if version is Version.Invalid:
        yield Error(messages.version_spec_malformed(
            location=location,
            compiler_version=COMPILER_VERSION,
        ))
    else:
        if not version.is_compatible_with(COMPILER_VERSION):
            yield Error(messages.compiler_version_incompatible_with_source(
                location=location,
                compiler_version=COMPILER_VERSION,
                source_version_spec=spec_string,
            ))
예제 #4
0
파일: versioning.py 프로젝트: turboza/quark
def version_spec_string_messages(spec_string, location):
    version = Version.parse(spec_string)

    if version is Version.Invalid:
        yield Error(
            messages.version_spec_malformed(
                location=location,
                compiler_version=COMPILER_VERSION,
            ))
    else:
        if not version.is_compatible_with(COMPILER_VERSION):
            yield Error(
                messages.compiler_version_incompatible_with_source(
                    location=location,
                    compiler_version=COMPILER_VERSION,
                    source_version_spec=spec_string,
                ))