BUILD 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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("@rules_python//python:defs.bzl", "py_library", "py_test")
  6. package(default_visibility = ["//explorer/parse_and_execute:__pkg__"])
  7. cc_library(
  8. name = "bison_wrap",
  9. hdrs = ["bison_wrap.h"],
  10. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  11. # don't spend time linting it.
  12. tags = ["no-clang-tidy"],
  13. deps = ["//common:check"],
  14. )
  15. cc_test(
  16. name = "parse_test",
  17. size = "small",
  18. srcs = ["parse_test.cpp"],
  19. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  20. # don't spend time linting it.
  21. tags = ["no-clang-tidy"],
  22. deps = [
  23. ":syntax",
  24. "//explorer/base:arena",
  25. "//testing/base:gtest_main",
  26. "@googletest//:gtest",
  27. ],
  28. )
  29. cc_library(
  30. name = "parse_test_matchers",
  31. testonly = 1,
  32. srcs = ["parse_test_matchers_internal.h"],
  33. hdrs = ["parse_test_matchers.h"],
  34. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  35. # don't spend time linting it.
  36. tags = ["no-clang-tidy"],
  37. deps = [
  38. ":syntax",
  39. "@googletest//:gtest",
  40. "@llvm-project//llvm:Support",
  41. ],
  42. )
  43. cc_library(
  44. name = "prelude",
  45. srcs = ["prelude.cpp"],
  46. hdrs = ["prelude.h"],
  47. data = ["//explorer:standard_libraries"],
  48. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  49. # don't spend time linting it.
  50. tags = ["no-clang-tidy"],
  51. deps = [
  52. ":syntax",
  53. "//common:error",
  54. "//explorer/ast",
  55. "//explorer/base:arena",
  56. "//explorer/base:nonnull",
  57. "@llvm-project//llvm:Support",
  58. ],
  59. )
  60. cc_library(
  61. name = "syntax",
  62. srcs = [
  63. "lex_helper.h",
  64. "lex_scan_helper.cpp",
  65. "lex_scan_helper.h",
  66. "lexer.cpp",
  67. "lexer.h",
  68. "parse.cpp",
  69. "parse_and_lex_context.cpp",
  70. "parse_and_lex_context.h",
  71. "parser.cpp",
  72. "parser.h",
  73. ],
  74. hdrs = [
  75. "parse.h",
  76. ],
  77. # Disable warnings for generated code.
  78. copts = [
  79. "-Wno-implicit-fallthrough", # Needed to make yyinput() code compile.
  80. "-Wno-unneeded-internal-declaration",
  81. "-Wno-unused-but-set-variable",
  82. "-Wno-unused-function",
  83. "-Wno-writable-strings",
  84. "-Wno-zero-as-null-pointer-constant",
  85. ],
  86. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  87. # don't spend time linting it.
  88. tags = ["no-clang-tidy"],
  89. visibility = [
  90. "//explorer/parse_and_execute:__pkg__",
  91. ],
  92. deps = [
  93. ":bison_wrap",
  94. "//common:check",
  95. "//common:error",
  96. "//common:ostream",
  97. "//common:string_helpers",
  98. "//explorer/ast",
  99. "//explorer/ast:expression_category",
  100. "//explorer/ast:paren_contents",
  101. "//explorer/base:arena",
  102. "//explorer/base:error_builders",
  103. "//explorer/base:nonnull",
  104. "//explorer/base:source_location",
  105. "@llvm-project//llvm:Support",
  106. ],
  107. )
  108. genrule(
  109. name = "syntax_bison_srcs",
  110. srcs = ["parser.ypp"],
  111. outs = [
  112. "parser.cpp",
  113. "parser.h",
  114. "parser.output",
  115. ],
  116. cmd = "M4=$(M4) $(BISON) " +
  117. "--output=$(location parser.cpp) " +
  118. "--report=state " +
  119. "--defines=$(location parser.h) " +
  120. "$(location parser.ypp)",
  121. toolchains = [
  122. "@rules_bison//bison:current_bison_toolchain",
  123. "@rules_m4//m4:current_m4_toolchain",
  124. ],
  125. )
  126. genrule(
  127. name = "syntax_flex_srcs",
  128. srcs = ["lexer.lpp"],
  129. outs = [
  130. "lexer.cpp",
  131. "lexer.h",
  132. ],
  133. cmd = "M4=$(M4) $(FLEX) " +
  134. "--outfile=$(location lexer.cpp) " +
  135. "--header-file=$(location lexer.h) " +
  136. "$(location lexer.lpp)",
  137. toolchains = [
  138. "@rules_flex//flex:current_flex_toolchain",
  139. "@rules_m4//m4:current_m4_toolchain",
  140. ],
  141. )
  142. py_library(
  143. name = "format_grammar_lib",
  144. srcs = ["format_grammar.py"],
  145. )
  146. py_test(
  147. name = "format_grammar_test",
  148. size = "small",
  149. srcs = ["format_grammar_test.py"],
  150. deps = ["format_grammar_lib"],
  151. )
  152. cc_test(
  153. name = "unimplemented_example_test",
  154. size = "small",
  155. srcs = ["unimplemented_example_test.cpp"],
  156. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  157. # don't spend time linting it.
  158. tags = ["no-clang-tidy"],
  159. deps = [
  160. ":parse_test_matchers",
  161. ":syntax",
  162. "//explorer/ast:ast_test_matchers",
  163. "//testing/base:gtest_main",
  164. "@googletest//:gtest",
  165. ],
  166. )