BUILD 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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("//testing/fuzzing:rules.bzl", "cc_fuzz_test")
  6. package(default_visibility = ["//visibility:public"])
  7. filegroup(
  8. name = "testdata",
  9. data = glob(["testdata/**/*.carbon"]),
  10. )
  11. cc_library(
  12. name = "node_kind",
  13. srcs = ["node_kind.cpp"],
  14. hdrs = [
  15. "node_ids.h",
  16. "node_kind.h",
  17. "typed_nodes.h",
  18. ],
  19. textual_hdrs = ["node_kind.def"],
  20. deps = [
  21. "//common:check",
  22. "//common:enum_base",
  23. "//common:ostream",
  24. "//toolchain/base:index_base",
  25. "//toolchain/lex:token_index",
  26. "//toolchain/lex:token_kind",
  27. "@llvm-project//llvm:Support",
  28. ],
  29. )
  30. cc_test(
  31. name = "typed_nodes_test",
  32. size = "small",
  33. srcs = ["typed_nodes_test.cpp"],
  34. deps = [
  35. ":node_kind",
  36. ":parse",
  37. ":tree",
  38. "//testing/base:gtest_main",
  39. "//toolchain/diagnostics:diagnostic_emitter",
  40. "//toolchain/diagnostics:mocks",
  41. "//toolchain/lex",
  42. "//toolchain/lex:tokenized_buffer",
  43. "@googletest//:gtest",
  44. ],
  45. )
  46. cc_library(
  47. name = "context",
  48. srcs = ["context.cpp"],
  49. hdrs = ["context.h"],
  50. deps = [
  51. ":node_kind",
  52. ":precedence",
  53. ":state",
  54. ":tree",
  55. "//common:check",
  56. "//common:ostream",
  57. "//common:vlog",
  58. "//toolchain/lex:token_kind",
  59. "//toolchain/lex:tokenized_buffer",
  60. "@llvm-project//llvm:Support",
  61. ],
  62. )
  63. cc_library(
  64. name = "parse",
  65. srcs = ["parse.cpp"] +
  66. # Glob handler files to avoid missing any.
  67. glob([
  68. "handle_*.cpp",
  69. ]),
  70. hdrs = [
  71. "handle.h",
  72. "parse.h",
  73. ],
  74. deps = [
  75. ":context",
  76. ":node_kind",
  77. ":state",
  78. ":tree",
  79. "//common:check",
  80. "//common:ostream",
  81. "//toolchain/base:pretty_stack_trace_function",
  82. "//toolchain/base:value_store",
  83. "//toolchain/diagnostics:diagnostic_emitter",
  84. "//toolchain/lex:token_kind",
  85. "//toolchain/lex:tokenized_buffer",
  86. ],
  87. )
  88. cc_library(
  89. name = "state",
  90. srcs = ["state.cpp"],
  91. hdrs = ["state.h"],
  92. textual_hdrs = ["state.def"],
  93. deps = ["//common:enum_base"],
  94. )
  95. cc_library(
  96. name = "tree",
  97. srcs = [
  98. "extract.cpp",
  99. "tree.cpp",
  100. ],
  101. hdrs = ["tree.h"],
  102. deps = [
  103. ":node_kind",
  104. "//common:check",
  105. "//common:error",
  106. "//common:ostream",
  107. "//common:struct_reflection",
  108. "//toolchain/lex:tokenized_buffer",
  109. "@llvm-project//llvm:Support",
  110. ],
  111. )
  112. cc_test(
  113. name = "tree_test",
  114. size = "small",
  115. srcs = ["tree_test.cpp"],
  116. deps = [
  117. ":node_kind",
  118. ":parse",
  119. ":tree",
  120. "//common:ostream",
  121. "//testing/base:gtest_main",
  122. "//testing/base:test_raw_ostream",
  123. "//toolchain/base:value_store",
  124. "//toolchain/diagnostics:diagnostic_emitter",
  125. "//toolchain/diagnostics:mocks",
  126. "//toolchain/lex",
  127. "//toolchain/lex:tokenized_buffer",
  128. "//toolchain/testing:yaml_test_helpers",
  129. "@googletest//:gtest",
  130. "@llvm-project//llvm:Support",
  131. ],
  132. )
  133. cc_fuzz_test(
  134. name = "parse_fuzzer",
  135. size = "small",
  136. srcs = ["parse_fuzzer.cpp"],
  137. corpus = glob(["fuzzer_corpus/*"]),
  138. deps = [
  139. ":parse",
  140. "//common:check",
  141. "//testing/fuzzing:libfuzzer_header",
  142. "//toolchain/base:value_store",
  143. "//toolchain/diagnostics:diagnostic_emitter",
  144. "//toolchain/diagnostics:null_diagnostics",
  145. "//toolchain/lex",
  146. "@llvm-project//llvm:Support",
  147. ],
  148. )
  149. cc_library(
  150. name = "tree_node_diagnostic_converter",
  151. hdrs = ["tree_node_diagnostic_converter.h"],
  152. deps = [
  153. ":tree",
  154. "//toolchain/diagnostics:diagnostic_emitter",
  155. "//toolchain/lex:tokenized_buffer",
  156. ],
  157. )
  158. cc_library(
  159. name = "precedence",
  160. srcs = ["precedence.cpp"],
  161. hdrs = ["precedence.h"],
  162. deps = [
  163. "//common:check",
  164. "//toolchain/lex:token_kind",
  165. "@llvm-project//llvm:Support",
  166. ],
  167. )
  168. cc_test(
  169. name = "precedence_test",
  170. size = "small",
  171. srcs = ["precedence_test.cpp"],
  172. deps = [
  173. ":precedence",
  174. "//testing/base:gtest_main",
  175. "//toolchain/lex:token_kind",
  176. "@googletest//:gtest",
  177. ],
  178. )