BUILD 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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/fuzzing:__pkg__",
  91. "//explorer/parse_and_execute:__pkg__",
  92. ],
  93. deps = [
  94. ":bison_wrap",
  95. "//common:check",
  96. "//common:error",
  97. "//common:ostream",
  98. "//common:string_helpers",
  99. "//explorer/ast",
  100. "//explorer/ast:expression_category",
  101. "//explorer/ast:paren_contents",
  102. "//explorer/base:arena",
  103. "//explorer/base:error_builders",
  104. "//explorer/base:nonnull",
  105. "//explorer/base:source_location",
  106. "@llvm-project//llvm:Support",
  107. ],
  108. )
  109. genrule(
  110. name = "syntax_bison_srcs",
  111. srcs = ["parser.ypp"],
  112. outs = [
  113. "parser.cpp",
  114. "parser.h",
  115. "parser.output",
  116. ],
  117. cmd = "M4=$(M4) $(BISON) " +
  118. "--output=$(location parser.cpp) " +
  119. "--report=state " +
  120. "--defines=$(location parser.h) " +
  121. "$(location parser.ypp)",
  122. toolchains = [
  123. "@rules_bison//bison:current_bison_toolchain",
  124. "@rules_m4//m4:current_m4_toolchain",
  125. ],
  126. )
  127. genrule(
  128. name = "syntax_flex_srcs",
  129. srcs = ["lexer.lpp"],
  130. outs = [
  131. "lexer.cpp",
  132. "lexer.h",
  133. ],
  134. cmd = "M4=$(M4) $(FLEX) " +
  135. "--outfile=$(location lexer.cpp) " +
  136. "--header-file=$(location lexer.h) " +
  137. "$(location lexer.lpp)",
  138. toolchains = [
  139. "@rules_flex//flex:current_flex_toolchain",
  140. "@rules_m4//m4:current_m4_toolchain",
  141. ],
  142. )
  143. py_library(
  144. name = "format_grammar_lib",
  145. srcs = ["format_grammar.py"],
  146. )
  147. py_test(
  148. name = "format_grammar_test",
  149. size = "small",
  150. srcs = ["format_grammar_test.py"],
  151. deps = ["format_grammar_lib"],
  152. )
  153. cc_test(
  154. name = "unimplemented_example_test",
  155. size = "small",
  156. srcs = ["unimplemented_example_test.cpp"],
  157. # Running clang-tidy is slow, and explorer is currently feature frozen, so
  158. # don't spend time linting it.
  159. tags = ["no-clang-tidy"],
  160. deps = [
  161. ":parse_test_matchers",
  162. ":syntax",
  163. "//explorer/ast:ast_test_matchers",
  164. "//testing/base:gtest_main",
  165. "@googletest//:gtest",
  166. ],
  167. )