BUILD 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 = [
  5. "//explorer:__pkg__",
  6. "//explorer/fuzzing:__pkg__",
  7. ])
  8. cc_library(
  9. name = "bison_wrap",
  10. hdrs = ["bison_wrap.h"],
  11. deps = ["//common:check"],
  12. )
  13. cc_test(
  14. name = "parse_test",
  15. srcs = ["parse_test.cpp"],
  16. deps = [
  17. ":syntax",
  18. "//common:gtest_main",
  19. "//explorer/common:arena",
  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/common:arena",
  44. "//explorer/common:nonnull",
  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. deps = [
  73. ":bison_wrap",
  74. "//common:check",
  75. "//common:error",
  76. "//common:ostream",
  77. "//common:string_helpers",
  78. "//explorer/ast",
  79. "//explorer/ast:paren_contents",
  80. "//explorer/ast:value_category",
  81. "//explorer/common:arena",
  82. "//explorer/common:error_builders",
  83. "//explorer/common:nonnull",
  84. "@llvm-project//llvm:Support",
  85. ],
  86. )
  87. genrule(
  88. name = "syntax_bison_srcs",
  89. srcs = ["parser.ypp"],
  90. outs = [
  91. "parser.cpp",
  92. "parser.h",
  93. "parser.output",
  94. ],
  95. cmd = "M4=$(M4) $(BISON) " +
  96. "--output=$(location parser.cpp) " +
  97. "--report=state " +
  98. "--defines=$(location parser.h) " +
  99. "$(location parser.ypp)",
  100. toolchains = [
  101. "@rules_bison//bison:current_bison_toolchain",
  102. "@rules_m4//m4:current_m4_toolchain",
  103. ],
  104. )
  105. genrule(
  106. name = "syntax_flex_srcs",
  107. srcs = ["lexer.lpp"],
  108. outs = [
  109. "lexer.cpp",
  110. "lexer.h",
  111. ],
  112. cmd = "M4=$(M4) $(FLEX) " +
  113. "--outfile=$(location lexer.cpp) " +
  114. "--header-file=$(location lexer.h) " +
  115. "$(location lexer.lpp)",
  116. toolchains = [
  117. "@rules_flex//flex:current_flex_toolchain",
  118. "@rules_m4//m4:current_m4_toolchain",
  119. ],
  120. )
  121. py_library(
  122. name = "format_grammar_lib",
  123. srcs = ["format_grammar.py"],
  124. )
  125. py_test(
  126. name = "format_grammar_test",
  127. srcs = ["format_grammar_test.py"],
  128. deps = ["format_grammar_lib"],
  129. )
  130. cc_test(
  131. name = "unimplemented_example_test",
  132. srcs = ["unimplemented_example_test.cpp"],
  133. deps = [
  134. ":parse_test_matchers",
  135. ":syntax",
  136. "//common:gtest_main",
  137. "//explorer/ast:ast_test_matchers",
  138. "@com_google_googletest//:gtest",
  139. ],
  140. )