BUILD 3.8 KB

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