BUILD 3.8 KB

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