BUILD 3.6 KB

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