BUILD 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. "//toolchain/testing:compile_helper",
  44. "@googletest//:gtest",
  45. ],
  46. )
  47. cc_library(
  48. name = "context",
  49. srcs = ["context.cpp"],
  50. hdrs = ["context.h"],
  51. deps = [
  52. ":node_kind",
  53. ":precedence",
  54. ":state",
  55. ":tree",
  56. "//common:check",
  57. "//common:ostream",
  58. "//common:vlog",
  59. "//toolchain/diagnostics:format_providers",
  60. "//toolchain/lex:token_kind",
  61. "//toolchain/lex:tokenized_buffer",
  62. "@llvm-project//llvm:Support",
  63. ],
  64. )
  65. cc_library(
  66. name = "parse",
  67. srcs = ["parse.cpp"] +
  68. # Glob handler files to avoid missing any.
  69. glob([
  70. "handle_*.cpp",
  71. ]),
  72. hdrs = [
  73. "handle.h",
  74. "parse.h",
  75. ],
  76. deps = [
  77. ":context",
  78. ":node_kind",
  79. ":state",
  80. ":tree",
  81. "//common:check",
  82. "//common:ostream",
  83. "//toolchain/base:pretty_stack_trace_function",
  84. "//toolchain/base:value_store",
  85. "//toolchain/diagnostics:diagnostic_emitter",
  86. "//toolchain/diagnostics:format_providers",
  87. "//toolchain/lex:token_kind",
  88. "//toolchain/lex:tokenized_buffer",
  89. ],
  90. )
  91. cc_library(
  92. name = "state",
  93. srcs = ["state.cpp"],
  94. hdrs = ["state.h"],
  95. textual_hdrs = ["state.def"],
  96. deps = ["//common:enum_base"],
  97. )
  98. cc_library(
  99. name = "tree",
  100. srcs = [
  101. "extract.cpp",
  102. "tree.cpp",
  103. "tree_and_subtrees.cpp",
  104. ],
  105. hdrs = [
  106. "tree.h",
  107. "tree_and_subtrees.h",
  108. ],
  109. deps = [
  110. ":node_kind",
  111. "//common:check",
  112. "//common:error",
  113. "//common:ostream",
  114. "//common:struct_reflection",
  115. "//toolchain/lex:tokenized_buffer",
  116. "@llvm-project//llvm:Support",
  117. ],
  118. )
  119. cc_test(
  120. name = "tree_test",
  121. size = "small",
  122. srcs = ["tree_test.cpp"],
  123. deps = [
  124. ":node_kind",
  125. ":parse",
  126. ":tree",
  127. "//common:ostream",
  128. "//testing/base:gtest_main",
  129. "//testing/base:test_raw_ostream",
  130. "//toolchain/base:value_store",
  131. "//toolchain/diagnostics:diagnostic_emitter",
  132. "//toolchain/diagnostics:mocks",
  133. "//toolchain/lex",
  134. "//toolchain/lex:tokenized_buffer",
  135. "//toolchain/testing:compile_helper",
  136. "//toolchain/testing:yaml_test_helpers",
  137. "@googletest//:gtest",
  138. "@llvm-project//llvm:Support",
  139. ],
  140. )
  141. cc_fuzz_test(
  142. name = "parse_fuzzer",
  143. size = "small",
  144. srcs = ["parse_fuzzer.cpp"],
  145. corpus = glob(["fuzzer_corpus/*"]),
  146. deps = [
  147. ":parse",
  148. "//common:check",
  149. "//testing/fuzzing:libfuzzer_header",
  150. "//toolchain/base:value_store",
  151. "//toolchain/diagnostics:diagnostic_emitter",
  152. "//toolchain/diagnostics:null_diagnostics",
  153. "//toolchain/lex",
  154. "@llvm-project//llvm:Support",
  155. ],
  156. )
  157. cc_library(
  158. name = "tree_node_diagnostic_converter",
  159. hdrs = ["tree_node_diagnostic_converter.h"],
  160. deps = [
  161. ":tree",
  162. "//toolchain/diagnostics:diagnostic_emitter",
  163. "//toolchain/lex:tokenized_buffer",
  164. ],
  165. )
  166. cc_library(
  167. name = "precedence",
  168. srcs = ["precedence.cpp"],
  169. hdrs = ["precedence.h"],
  170. deps = [
  171. "//common:check",
  172. "//toolchain/lex:token_kind",
  173. "@llvm-project//llvm:Support",
  174. ],
  175. )
  176. cc_test(
  177. name = "precedence_test",
  178. size = "small",
  179. srcs = ["precedence_test.cpp"],
  180. deps = [
  181. ":precedence",
  182. "//testing/base:gtest_main",
  183. "//toolchain/lex:token_kind",
  184. "@googletest//:gtest",
  185. ],
  186. )