def METHOD_NAME(name, src, out, includes = []):
    """Generate a C++ lexer from a lex file using Flex.
    Args:
      name: The name of the rule.
      src: The .lex source file.
      out: The generated source file.
      includes: A list of headers included by the .lex file.
    """
    cmd = "$(LEX) -o $(@D)/%s $(location %s)" % (out, src)
    native.genrule(
        name = name,
        outs = [out],
        srcs = [src] + includes,
        cmd = cmd,
        toolchains = ["@io_kythe//tools/build_rules/lexyacc:current_lexyacc_toolchain"],
        tools = ["@io_kythe//tools/build_rules/lexyacc:current_lexyacc_toolchain"],
    )