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