BUILD 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 = ["node_kind.h"],
  16. textual_hdrs = ["node_kind.def"],
  17. deps = [
  18. "//common:check",
  19. "//common:enum_base",
  20. "//toolchain/lex:token_kind",
  21. ],
  22. )
  23. cc_library(
  24. name = "state",
  25. srcs = ["state.cpp"],
  26. hdrs = ["state.h"],
  27. textual_hdrs = ["state.def"],
  28. deps = ["//common:enum_base"],
  29. )
  30. cc_library(
  31. name = "tree",
  32. srcs = [
  33. "context.cpp",
  34. "context.h",
  35. "tree.cpp",
  36. ] +
  37. # Glob handler files to avoid missing any.
  38. glob([
  39. "handle_*.cpp",
  40. ]),
  41. hdrs = ["tree.h"],
  42. deps = [
  43. ":node_kind",
  44. ":precedence",
  45. ":state",
  46. "//common:check",
  47. "//common:error",
  48. "//common:ostream",
  49. "//common:vlog",
  50. "//toolchain/base:pretty_stack_trace_function",
  51. "//toolchain/base:value_store",
  52. "//toolchain/diagnostics:diagnostic_emitter",
  53. "//toolchain/lex:token_kind",
  54. "//toolchain/lex:tokenized_buffer",
  55. "@llvm-project//llvm:Support",
  56. ],
  57. )
  58. cc_test(
  59. name = "tree_test",
  60. size = "small",
  61. srcs = ["tree_test.cpp"],
  62. deps = [
  63. ":node_kind",
  64. ":tree",
  65. "//common:ostream",
  66. "//testing/base:gtest_main",
  67. "//testing/base:test_raw_ostream",
  68. "//toolchain/base:value_store",
  69. "//toolchain/diagnostics:diagnostic_emitter",
  70. "//toolchain/diagnostics:mocks",
  71. "//toolchain/lex",
  72. "//toolchain/lex:tokenized_buffer",
  73. "//toolchain/testing:yaml_test_helpers",
  74. "@com_google_googletest//:gtest",
  75. "@llvm-project//llvm:Support",
  76. ],
  77. )
  78. cc_fuzz_test(
  79. name = "parse_fuzzer",
  80. size = "small",
  81. srcs = ["parse_fuzzer.cpp"],
  82. corpus = glob(["fuzzer_corpus/*"]),
  83. deps = [
  84. ":tree",
  85. "//common:check",
  86. "//toolchain/base:value_store",
  87. "//toolchain/diagnostics:diagnostic_emitter",
  88. "//toolchain/diagnostics:null_diagnostics",
  89. "//toolchain/lex",
  90. "@llvm-project//llvm:Support",
  91. ],
  92. )
  93. cc_library(
  94. name = "tree_node_location_translator",
  95. hdrs = ["tree_node_location_translator.h"],
  96. deps = [":tree"],
  97. )
  98. cc_library(
  99. name = "precedence",
  100. srcs = ["precedence.cpp"],
  101. hdrs = ["precedence.h"],
  102. deps = [
  103. "//common:check",
  104. "//toolchain/lex:token_kind",
  105. "@llvm-project//llvm:Support",
  106. ],
  107. )
  108. cc_test(
  109. name = "precedence_test",
  110. size = "small",
  111. srcs = ["precedence_test.cpp"],
  112. deps = [
  113. ":precedence",
  114. "//testing/base:gtest_main",
  115. "//toolchain/lex:token_kind",
  116. "@com_google_googletest//:gtest",
  117. ],
  118. )
  119. glob_sh_run(
  120. args = [
  121. "$(location //toolchain/driver:carbon)",
  122. "compile",
  123. "--phase=parse",
  124. "--dump-parse-tree",
  125. ],
  126. data = ["//toolchain/driver:carbon"],
  127. file_exts = ["carbon"],
  128. )
  129. glob_sh_run(
  130. args = [
  131. "$(location //toolchain/driver:carbon)",
  132. "-v",
  133. "compile",
  134. "--phase=parse",
  135. ],
  136. data = ["//toolchain/driver:carbon"],
  137. file_exts = ["carbon"],
  138. run_ext = "verbose",
  139. )