BUILD 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. "tree_and_subtrees.cpp",
  101. ],
  102. hdrs = [
  103. "tree.h",
  104. "tree_and_subtrees.h",
  105. ],
  106. deps = [
  107. ":node_kind",
  108. "//common:check",
  109. "//common:error",
  110. "//common:ostream",
  111. "//common:struct_reflection",
  112. "//toolchain/lex:tokenized_buffer",
  113. "@llvm-project//llvm:Support",
  114. ],
  115. )
  116. cc_test(
  117. name = "tree_test",
  118. size = "small",
  119. srcs = ["tree_test.cpp"],
  120. deps = [
  121. ":node_kind",
  122. ":parse",
  123. ":tree",
  124. "//common:ostream",
  125. "//testing/base:gtest_main",
  126. "//testing/base:test_raw_ostream",
  127. "//toolchain/base:value_store",
  128. "//toolchain/diagnostics:diagnostic_emitter",
  129. "//toolchain/diagnostics:mocks",
  130. "//toolchain/lex",
  131. "//toolchain/lex:tokenized_buffer",
  132. "//toolchain/testing:yaml_test_helpers",
  133. "@googletest//:gtest",
  134. "@llvm-project//llvm:Support",
  135. ],
  136. )
  137. cc_fuzz_test(
  138. name = "parse_fuzzer",
  139. size = "small",
  140. srcs = ["parse_fuzzer.cpp"],
  141. corpus = glob(["fuzzer_corpus/*"]),
  142. deps = [
  143. ":parse",
  144. "//common:check",
  145. "//testing/fuzzing:libfuzzer_header",
  146. "//toolchain/base:value_store",
  147. "//toolchain/diagnostics:diagnostic_emitter",
  148. "//toolchain/diagnostics:null_diagnostics",
  149. "//toolchain/lex",
  150. "@llvm-project//llvm:Support",
  151. ],
  152. )
  153. cc_library(
  154. name = "tree_node_diagnostic_converter",
  155. hdrs = ["tree_node_diagnostic_converter.h"],
  156. deps = [
  157. ":tree",
  158. "//toolchain/diagnostics:diagnostic_emitter",
  159. "//toolchain/lex:tokenized_buffer",
  160. ],
  161. )
  162. cc_library(
  163. name = "precedence",
  164. srcs = ["precedence.cpp"],
  165. hdrs = ["precedence.h"],
  166. deps = [
  167. "//common:check",
  168. "//toolchain/lex:token_kind",
  169. "@llvm-project//llvm:Support",
  170. ],
  171. )
  172. cc_test(
  173. name = "precedence_test",
  174. size = "small",
  175. srcs = ["precedence_test.cpp"],
  176. deps = [
  177. ":precedence",
  178. "//testing/base:gtest_main",
  179. "//toolchain/lex:token_kind",
  180. "@googletest//:gtest",
  181. ],
  182. )