BUILD 3.7 KB

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