BUILD 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
  5. load("//bazel/sh_run:rules.bzl", "glob_sh_run")
  6. load("//testing/file_test:rules.bzl", "file_test")
  7. load("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  8. package(default_visibility = ["//visibility:public"])
  9. cc_library(
  10. name = "node_kind",
  11. srcs = ["node_kind.cpp"],
  12. hdrs = ["node_kind.h"],
  13. textual_hdrs = ["node_kind.def"],
  14. deps = [
  15. "//common:check",
  16. "//common:enum_base",
  17. ],
  18. )
  19. cc_library(
  20. name = "state",
  21. srcs = ["state.cpp"],
  22. hdrs = ["state.h"],
  23. textual_hdrs = ["state.def"],
  24. deps = ["//common:enum_base"],
  25. )
  26. cc_library(
  27. name = "tree",
  28. srcs = [
  29. "context.cpp",
  30. "context.h",
  31. "tree.cpp",
  32. ] +
  33. # Glob handler files to avoid missing any.
  34. glob([
  35. "handle_*.cpp",
  36. ]),
  37. hdrs = ["tree.h"],
  38. deps = [
  39. ":node_kind",
  40. ":precedence",
  41. ":state",
  42. "//common:check",
  43. "//common:error",
  44. "//common:ostream",
  45. "//common:vlog",
  46. "//toolchain/base:pretty_stack_trace_function",
  47. "//toolchain/diagnostics:diagnostic_emitter",
  48. "//toolchain/lex:token_kind",
  49. "//toolchain/lex:tokenized_buffer",
  50. "@llvm-project//llvm:Support",
  51. ],
  52. )
  53. cc_test(
  54. name = "tree_test",
  55. size = "small",
  56. srcs = ["tree_test.cpp"],
  57. deps = [
  58. ":node_kind",
  59. ":tree",
  60. "//common:ostream",
  61. "//testing/base:gtest_main",
  62. "//testing/base:test_raw_ostream",
  63. "//toolchain/base:yaml_test_helpers",
  64. "//toolchain/diagnostics:diagnostic_emitter",
  65. "//toolchain/diagnostics:mocks",
  66. "//toolchain/lex:tokenized_buffer",
  67. "@com_google_googletest//:gtest",
  68. "@llvm-project//llvm:Support",
  69. ],
  70. )
  71. cc_fuzz_test(
  72. name = "parse_fuzzer",
  73. size = "small",
  74. srcs = ["parse_fuzzer.cpp"],
  75. corpus = glob(["fuzzer_corpus/*"]),
  76. deps = [
  77. ":tree",
  78. "//common:check",
  79. "//toolchain/diagnostics:diagnostic_emitter",
  80. "//toolchain/diagnostics:null_diagnostics",
  81. "//toolchain/lex:tokenized_buffer",
  82. "@llvm-project//llvm:Support",
  83. ],
  84. )
  85. cc_library(
  86. name = "tree_node_location_translator",
  87. hdrs = ["tree_node_location_translator.h"],
  88. deps = [":tree"],
  89. )
  90. cc_library(
  91. name = "precedence",
  92. srcs = ["precedence.cpp"],
  93. hdrs = ["precedence.h"],
  94. deps = [
  95. "//common:check",
  96. "//toolchain/lex:token_kind",
  97. "@llvm-project//llvm:Support",
  98. ],
  99. )
  100. cc_test(
  101. name = "precedence_test",
  102. size = "small",
  103. srcs = ["precedence_test.cpp"],
  104. deps = [
  105. ":precedence",
  106. "//testing/base:gtest_main",
  107. "//toolchain/lex:token_kind",
  108. "@com_google_googletest//:gtest",
  109. ],
  110. )
  111. file_test(
  112. name = "parse_file_test",
  113. srcs = ["parse_file_test.cpp"],
  114. tests = glob(["testdata/**/*.carbon"]),
  115. deps = [
  116. "//toolchain/driver:driver_file_test_base",
  117. "@llvm-project//llvm:Support",
  118. ],
  119. )
  120. glob_sh_run(
  121. args = [
  122. "$(location //toolchain/driver:carbon)",
  123. "compile",
  124. "--phase=parse",
  125. "--dump-parse-tree",
  126. ],
  127. data = ["//toolchain/driver:carbon"],
  128. file_exts = ["carbon"],
  129. )
  130. glob_sh_run(
  131. args = [
  132. "$(location //toolchain/driver:carbon)",
  133. "-v",
  134. "compile",
  135. "--phase=parse",
  136. ],
  137. data = ["//toolchain/driver:carbon"],
  138. file_exts = ["carbon"],
  139. run_ext = "verbose",
  140. )