BUILD 3.9 KB

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